https://github.com/sleekpanther/loop-performance
https://github.com/sleekpanther/loop-performance
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sleekpanther/loop-performance
- Owner: SleekPanther
- Created: 2017-01-23T13:55:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-05T22:59:32.000Z (about 8 years ago)
- Last Synced: 2025-01-15T13:08:06.035Z (9 months ago)
- Language: Java
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Java Loop Performance with i++ & ++i
A simple demonstration of testing the runtimes of pre and post increment operators when applies to loopsTheoretically, `++i` should be faster as it doesn't need to copy the value, just increment it. `i++` fetches `i`, copies it, increments it & returns the copy.
**But this doesn't always work. Sometimes the difference (post - pre) calculated is negative, indicating the `i++` post incrementing was faster**All times in **nanoseconds**