A
A
Alex2020-01-29 12:29:35
JavaScript
Alex, 2020-01-29 12:29:35

How to measure script performance in CPU cycles?

I want to measure the performance of a certain piece of code. Now time measurements are used, using performance.now(). But time is not the most accurate indicator due to a bunch of background processes and various factors. I heard that in v8 you can somehow measure the number of processor cycles before and after the execution of my code. But somehow I can't find how to do it.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
beduin01, 2020-01-29
@beduin01

It is not the number of cycles that matters, but the number of instructions that are executed in one cycle.

V
Vasily Bannikov, 2020-01-29
@vabka

In fact, the number of cycles will give you little useful information. Profiling and benchmarks will
be noticeably more useful

A
asd111, 2020-01-29
@asd111

Use v8's built-in profiler https://v8.dev/docs/profile
It shows CPU clocks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question