Embercode
✕
Time and Space ComplexityQuick quiz

Benchmarks

6 questions. Covers Benchmarking honestly.

Questions 1 to 5 of 6

  1. 1. The Warm program in the lesson prints batch 1 at about 6312 us, and the later batches at about 4400 us. Why is batch 1 slower?
  2. 2. A C++ benchmark built with -O2, where the result of work(n) is not used, prints 0.000 ms for every run. What does this mean?
  3. 3. The first measured batch of a Java benchmark shows the steady speed of the code, so it is the number to report.
  4. 4. Timing one run of each version is enough to compare them, because the same code gives nearly the same time on every run.
  5. 5. The timing code below has a bug. Which one is it? ``java long start = System.nanoTime(); int[] data = new int[n]; for (int i = 0; i < n; i++) { data[i] = i % 100; } long total = sumArray(data); long elapsedMs = (System.nanoTime() - start) / 1_000_000; ` sumArray` is the method from the lesson.

5 question(s) left on this page.