Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CODE:
- clear all
- N_arr = [10000 100000 110000];
- num_approaches = 6;
- timeall = zeros(num_approaches,numel(N_arr));
- for k1 = 1:numel(N_arr)
- list_of_words = repmat({'02_04_04_52_23_14_54_672_0'},N_arr(k1),1); %// Input
- f1 = @() eval_and_loops_solution(list_of_words);
- timeall(1,k1) = timeit(f1);
- clear f1
- f2 = @() single_sscanf_solution(list_of_words);
- timeall(2,k1) = timeit(f2);
- clear f2
- f3 = @() approach1(list_of_words);
- timeall(3,k1) = timeit(f3);
- clear f3
- f4 = @() approach4(list_of_words);
- timeall(4,k1) = timeit(f4);
- clear f4
- f5 = @() extractIntsSprintfTextScan(list_of_words);
- timeall(5,k1) = timeit(f5);
- clear f5
- f6 = @() char_and_sscanf_solution(list_of_words);
- timeall(6,k1) = timeit(f6);
- clear f6
- end
- RESULTS:
- timeall =
- 0.166590579510894 1.69688406501487 1.858701404868
- 0.182020158046702 1.86830397839867 2.0617517077289
- 0.0467952604573387 0.487110367775646 0.529473725759845
- 0.0372419911866739 0.351480037463652 0.384186207967644
- 0.0425145128985633 0.396989765763046 0.43853581082183
- 0.052280549014313 0.525830899472786 0.577675087391801
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement