Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--export-json option does not follow --time-unit millisecond #506

Closed
LakshyAAAgrawal opened this issue May 3, 2022 · 1 comment
Closed
Labels

Comments

@LakshyAAAgrawal
Copy link

When I run hyperfine as follows:

hyperfine --export-json export_file.json --time-unit millisecond ...

The information printed on screen contains the runtime in ms, but the values in json are in seconds.

STDOUT:

Benchmark 1:
  Time (mean ± σ):     24338.2 ms ± 586.0 ms    [User: 33456.5 ms, System: 810.7 ms]
  Range (min … max):   23236.7 ms … 24935.3 ms    10 runs

Benchmark 2:
  Time (mean ± σ):     30608.8 ms ± 1589.9 ms    [User: 30179.0 ms, System: 370.1 ms]
  Range (min … max):   28544.2 ms … 33266.7 ms    10 runs

Benchmark 3:
  Time (mean ± σ):     2440.0 ms ± 110.5 ms    [User: 7190.9 ms, System: 510.5 ms]
  Range (min … max):   2320.6 ms … 2687.1 ms    10 runs

Benchmark 4: 
  Time (mean ± σ):     271.3 ms ±   9.7 ms    [User: 277.8 ms, System: 43.0 ms]
  Range (min … max):   261.7 ms … 287.7 ms    11 runs

JSON:

{
  "results": [
    {
      "command": "",
      "mean": 24.33821241768,
      "stddev": 0.5860376164918488,
      "median": 24.519336471680003,
      "user": 33.45652016,
      "system": 0.8106670799999998,
      "min": 23.236672976180003,
      "max": 24.935324420180002,
      "times": [
        24.377126650180003,
        24.935324420180002,
        23.673355310180003,
        24.860536787180003,
        24.71504739118,
        24.013392875180003,
        23.236672976180003,
        24.661546293180002,
        24.91582306918,
        23.993298404180003
      ],
      "exit_codes": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ],
      "parameters": {
        ...
      }
    },
    {
      "command": "",
      "mean": 30.608782593479997,
      "stddev": 1.589898056911429,
      "median": 30.16905129018,
      "user": 30.17903756,
      "system": 0.37007848,
      "min": 28.544227869180002,
      "max": 33.26665792318,
      "times": [
        29.665700734180003,
        29.242187895180002,
        28.544227869180002,
        29.26461614718,
        33.26665792318,
        31.94330033318,
        29.61887199018,
        30.67240184618,
        31.397677382180003,
        32.47218381418
      ],
      "exit_codes": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ],
      "parameters": {
        ...
      }
    },
    {
      "command": "",
      "mean": 2.44003735098,
      "stddev": 0.11049737756969906,
      "median": 2.40457368518,
      "user": 7.1908692599999995,
      "system": 0.51047328,
      "min": 2.32056399918,
      "max": 2.6871016281799998,
      "times": [
        2.6871016281799998,
        2.50202483118,
        2.37684932518,
        2.53409697118,
        2.3867186171799997,
        2.45987207818,
        2.35651591618,
        2.35420139018,
        2.32056399918,
        2.4224287531799997
      ],
      "exit_codes": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ],
      "parameters": {
        ...
      }
    },
    {
      "command": "..",
      "mean": 0.2713198007254546,
      "stddev": 0.009676558478438305,
      "median": 0.26807056817999997,
      "user": 0.2778479418181818,
      "system": 0.043043134545454546,
      "min": 0.26173708417999997,
      "max": 0.28768982918,
      "times": [
        0.26173708417999997,
        0.27555605518,
        0.28768982918,
        0.27888181118,
        0.28593935018,
        0.26807056817999997,
        0.26298405418,
        0.26192160718,
        0.27402342418,
        0.26329744018,
        0.26441658417999997
      ],
      "exit_codes": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ],
      "parameters": {
           ...
      }
    }
  ]
}
@sharkdp
Copy link
Owner

sharkdp commented May 16, 2022

The information printed on screen contains the runtime in ms, but the values in json are in seconds.

Yes, that is expected. We want the JSON format to be a format for interchange between hyperfine and other tools. We therefore fix the times to be in seconds.

--time-unit only influences what is being displayed on the console... and other (markup) export formats.

This should probably be clarified in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants