Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. CODE:
  2.  
  3. clear all
  4. N_arr = [10000 100000 110000];
  5. num_approaches = 6;
  6. timeall = zeros(num_approaches,numel(N_arr));
  7. for k1 = 1:numel(N_arr)
  8. list_of_words = repmat({'02_04_04_52_23_14_54_672_0'},N_arr(k1),1); %// Input
  9.  
  10. f1 = @() eval_and_loops_solution(list_of_words);
  11. timeall(1,k1) = timeit(f1);
  12. clear f1
  13.  
  14. f2 = @() single_sscanf_solution(list_of_words);
  15. timeall(2,k1) = timeit(f2);
  16. clear f2
  17.  
  18. f3 = @() approach1(list_of_words);
  19. timeall(3,k1) = timeit(f3);
  20. clear f3
  21.  
  22. f4 = @() approach4(list_of_words);
  23. timeall(4,k1) = timeit(f4);
  24. clear f4
  25.  
  26. f5 = @() extractIntsSprintfTextScan(list_of_words);
  27. timeall(5,k1) = timeit(f5);
  28. clear f5
  29.  
  30. f6 = @() char_and_sscanf_solution(list_of_words);
  31. timeall(6,k1) = timeit(f6);
  32. clear f6
  33.  
  34. end
  35.  
  36. RESULTS:
  37. timeall =
  38. 0.166590579510894 1.69688406501487 1.858701404868
  39. 0.182020158046702 1.86830397839867 2.0617517077289
  40. 0.0467952604573387 0.487110367775646 0.529473725759845
  41. 0.0372419911866739 0.351480037463652 0.384186207967644
  42. 0.0425145128985633 0.396989765763046 0.43853581082183
  43. 0.052280549014313 0.525830899472786 0.577675087391801
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement