Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function speed_test()
- test_struct.inc = @increase;
- var = 1;
- tic
- for some_load = 1:1e6
- var = var + 1;
- end
- toc
- var = 1;
- tic
- for some_load = 1:1e6
- var = increase(var);
- end
- toc
- test_struct.var = 1;
- tic
- for some_load = 1:1e6
- test_struct.var = test_struct.var + 1;
- end
- toc
- var = 1;
- tic
- for some_load = 1:1e6
- var = test_struct.inc(var);
- end
- toc
- end
- function a = increase(b)
- a = b + 1;
- end
- function a = increase(b)
- a = b + 1;
- end
- ---------------------
- Elapsed time is 0.003451 seconds.
- Elapsed time is 0.024997 seconds.
- Elapsed time is 0.248971 seconds.
- Elapsed time is 1.112444 seconds.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement