Sunday, May 24, 2020

Ask HN: Is it possible to do idempotent microbenchmarks?

Given a program with a fixed input and output. Is it possible to do a microbenchmark in an idempotent unit related to the work performed to compute the output?

In other words, If you run the same program multiple times with the same input, the benchmark should always result in the same value.

For instance, this node.js program. I want to run it multiple times and have the same benchmark value.

  // Brute force: O(n^2) | O(1)
  function twoSum(nums, target) {
    for (let i = 0; i < nums.length - 1; i++) { // O(n^2)
      for (let j = i + 1; j < nums.length; j++) { // O(n)
        if (nums[i] + nums[j] === target) {
          return [i, j];
        }
      }
    }
    return [];
  }

  console.log(twoSum(Array(1e7).fill(2), 4));

Comments URL: https://news.ycombinator.com/item?id=23296013

Points: 1

# Comments: 0



from Hacker News: Newest https://ift.tt/3eaIt2s
via IFTTT

No comments:

Post a Comment

Multimodal embeddings for interleaved text and images

Article URL: https://docs.voyageai.com/docs/multimodal-embeddings Comments URL: https://news.ycombinator.com/item?id=42020484 Points: 3 #...