> The manual test Cipher/DES/PerformanceTest.java fails with > ArithmeticException due to potential division by zero. The issue arises when > calculating the elapsed time using end - start, which could result in zero > milliseconds if start and end are identical due to the high speed of > execution. This leads to a division error in the following code snippet: > > > start = System.currentTimeMillis(); > end = System.currentTimeMillis(); > int speed = (int)((data.length * count)/(end - start)); > > This issue is easily reproducible on platforms where > System.currentTimeMillis() has low precision, such as many versions of > Windows, end and start can be equal when obtaining System.currentTimeMillis() > if the test runs very quickly. > > The fix is to provide a default value in case _end_ is not higher than > _start_.
Fernando Guallini has updated the pull request incrementally with one additional commit since the last revision: use microseconds as time unit ------------- Changes: - all: https://git.openjdk.org/jdk/pull/20135/files - new: https://git.openjdk.org/jdk/pull/20135/files/ad4b94b3..03bae4c6 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=20135&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=20135&range=00-01 Stats: 10 lines in 1 file changed: 4 ins; 2 del; 4 mod Patch: https://git.openjdk.org/jdk/pull/20135.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/20135/head:pull/20135 PR: https://git.openjdk.org/jdk/pull/20135