Skip to content

src: add support to pretty and json output#4

Merged
RafaelGSS merged 3 commits intomainfrom
rafael/pretty-output
Mar 6, 2024
Merged

src: add support to pretty and json output#4
RafaelGSS merged 3 commits intomainfrom
rafael/pretty-output

Conversation

@RafaelGSS
Copy link
Copy Markdown
Member

This commit adds support to console output and JSON output. It checks if the script was run without echoing to a file:

$ node index.js
Running Node.js Package Benchmark...
----------------------------------------------------------
babel
  transform (code=true ast=true):                         70.09 (3 samples)
  transform (code=false):                                 78.57 (2 samples)
dotenv
  config:                                                 31.09K (5 samples)
lodash
  .chunk:                                                 24.47M (5 samples)
  .groupBy:                                               3.343M (7 samples)
  .includes:                                              10.35M (6 samples)
  .orderBy:                                               921.3K (8 samples)
moment
  format (full):                                          504.7K (7 samples)
  format:                                                 441K (4 samples)
  fromNow (YYYYMMDD):                                     73K (9 samples)
  subtract (10):                                          134K (5 samples)
pinojs
  info (10x):                                             109.1K (4 samples)
prettier
  format (semi=true):                                     773.5K (3 samples)
  format (singleQuote=true semi=true tabs=true):          593.7K (3 samples)
  format (singleQuote=false semi=false tabs=false):       473.4K (3 samples)
underscore
  .chunk:                                                 3.15M (3 samples)
  .groupBy:                                               1.003M (3 samples)
  .includes:                                              6.588M (4 samples)
  .orderBy:                                               488.7K (5 samples)
winston
  info (10x):                                             24.48K (4 samples)

Then calling pretty console output, or when pipe is found

$ node index.js > results.json
$ cat result.json
[
  {
    "name": "babel",
    "method": "benchmarkjs",
    "operations": [
      {
        "name": "transform (code=true ast=true)",
        "opsSec": 67.80076532539411,
        "samples": 3
      },
      {
...

Resulting in a JSON output.


Depends on #3

@RafaelGSS RafaelGSS requested review from edsadr and santigimeno March 4, 2024 20:05
@RafaelGSS RafaelGSS changed the base branch from rafael/add-new-packages to main March 6, 2024 20:25
This commit add supports to console output
and JSON output. It checks if the script
was run without echoing to a file:
```
$ node index.js
```

Then caling pretty console ouput, or when
pipe is found
```
$ node index.js > results.json
```

Resulting in a JSON output.
@RafaelGSS RafaelGSS force-pushed the rafael/pretty-output branch from bc736be to 6567798 Compare March 6, 2024 20:30
@RafaelGSS RafaelGSS merged commit 82082f1 into main Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants