Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%%%%%%% FILE SomeHeterogeneousClass.m
- classdef SomeHeterogeneousClass < matlab.mixin.Heterogeneous
- properties (Access=public)
- data
- end
- methods (Access=public)
- function this=SomeHeterogeneousClass(i)
- this.data = i;
- end
- end
- end
- %%%%%%%%% FILE testMaps.m
- function testMaps()
- N = 65535;
- timeBegin = tic();
- m=containers.Map('KeyType', 'uint32', 'ValueType', 'uint32');
- for (i = uint32(1:N))
- m(i) = i;
- end
- fprintf('Maps took %.5d seconds.\n', toc(timeBegin));
- whos m
- clear m timeBegin;
- timeBegin = tic();
- m=cell(N,1);
- for (i = uint32(1:N))
- m{i} = i;
- end
- fprintf('Cells took %.5d seconds.\n', toc(timeBegin));
- whos m
- clear m timeBegin;
- timeBegin = tic();
- m=SomeHeterogeneousClass.empty(0,N);
- for (i = uint32(1:N))
- m(i) = SomeHeterogeneousClass(i);
- end
- fprintf('Heterogeneous array took %.5d seconds.\n', toc(timeBegin));
- whos m
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement