diff options
| author | nasr <nsrddyn@gmail.com> | 2025-11-20 21:41:41 +0100 |
|---|---|---|
| committer | nasr <nsrddyn@gmail.com> | 2025-11-20 21:41:41 +0100 |
| commit | 694f5afeff9a26b4fe1ccf2b9741089a2ac1f226 (patch) | |
| tree | 129ccfbaef532eb8924f71cfab6b3222a5d14b95 /src/main/scala/com/nsrddyn/Tools | |
| parent | b96c4615cdae285f613f757ae9381317249bf1fc (diff) | |
feature: implement Benchmark class and PrimeTest for performance measurement
Diffstat (limited to 'src/main/scala/com/nsrddyn/Tools')
| -rw-r--r-- | src/main/scala/com/nsrddyn/Tools/Benchmark.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/scala/com/nsrddyn/Tools/Benchmark.scala b/src/main/scala/com/nsrddyn/Tools/Benchmark.scala new file mode 100644 index 0000000..a0b388b --- /dev/null +++ b/src/main/scala/com/nsrddyn/Tools/Benchmark.scala @@ -0,0 +1,17 @@ +package com.nsrddyn.tools + +class Benchmark { + /* + * Calculate the time between the start of the execution of the function and the end + * */ + def measureTime(work: => Unit): Long = { + + val start = System.nanoTime() + work + val end = System.nanoTime() + end - start + } + + // TODO: map this to an actual precision value + def measurePrecision(work: => Boolean, expectedResult: Boolean): Unit = if work == expectedResult then println(true) else println(false) +} |
