Skip to content

The number of clocks is not calculated correctly in QuickJS runtimes #63

@nabetti1720

Description

@nabetti1720

First of all, thank you for publishing this great benchmark suite!

I have been involved in the development of LLRT a little bit. The great thing is that mitata seems to support LLRT as well, which is very useful for quick testing, but I'm encountering a slightly strange phenomenon.

I have provided a simple script below, but it seems that the clk number is not displayed correctly in this script or any script.

// concat.js
import { run, bench, group, summary } from 'mitata'

const chars = Array.from({ length: 100_000 }, () =>
  String.fromCharCode(97 + Math.floor(Math.random() * 26))
);

group('String concatenation (100,000 chars)', () => {
  summary(() => {
    bench('using + operator', () => {
      let result = '';
      for (let i = 0; i < chars.length; i++) {
        result += chars[i];
      }
      return result;
    });
  });
});

await run();
% llrt bench/llrt/concat.js
clk: ~0.03 GHz
cpu: Apple M2
runtime: llrt 0.7.0-beta (arm64-darwin)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
• String concatenation (100,000 chars)
------------------------------------------- -------------------------------
using + operator             278.87 ms/iter 280.20 ms                  ██ █
                    (263.43 ms … 309.77 ms) 280.76 ms █▁▁▁█▁▁▁▁▁▁▁█▁▁█▁████

This issue also occurs in bellard/quickjs (2025-09-13).

EDIT: When I run the same script in Node.js, the results are fine.

% node bench/llrt/concat.js                   
clk: ~3.23 GHz
cpu: Apple M2
runtime: node 24.3.0 (arm64-darwin)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
• String concatenation (100,000 chars)
------------------------------------------- -------------------------------
using + operator             377.10 µs/iter 331.54 µs █                    
                      (291.38 µs … 2.38 ms)   1.36 ms █▂                   
                    (  1.99 mb …   3.22 mb)   3.05 mb ██▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions