-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
benchmark: improve compare output #18597
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
'use strict'; | ||
|
||
const fork = require('child_process').fork; | ||
const { fork } = require('child_process'); | ||
const { inspect } = require('util'); | ||
const path = require('path'); | ||
const CLI = require('./_cli.js'); | ||
const BenchmarkProgress = require('./_benchmark_progress.js'); | ||
|
@@ -76,11 +77,9 @@ if (showProgress) { | |
// Construct configuration string, " A=a, B=b, ..." | ||
let conf = ''; | ||
for (const key of Object.keys(data.conf)) { | ||
conf += ` ${key}=${JSON.stringify(data.conf[key])}`; | ||
conf += ` ${key}=${inspect(data.conf[key])}`; | ||
} | ||
conf = conf.slice(1); | ||
// Escape quotes (") for correct csv formatting | ||
conf = conf.replace(/"/g, '""'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seconding this question. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uh, you are right. I was a bit hasty here. I revert that change. |
||
|
||
console.log(`"${job.binary}", "${job.filename}", "${conf}", ` + | ||
`${data.rate}, ${data.time}`); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually wondering, is there a place where we benefit from using
inspect
here as opposed to simplyString(data.conf[key])
? Because as far as I can tell,conf
is generally number, string or true/false.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do because we will actually be able to distinguish the data types by using
util.inspect
. By only converting it to a string, the string'true'
would look the same as the booleantrue
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair.
Personally, I'm not sure I actually love that part of the functionality but obviously that's not something that needs to be addressed in this PR. Since it's generating CSV, having true and "true" be equivalent is almost preferable to me.
One other thing...
util.inspect
will do the following:The former doesn't seem correct for the purposes of CSV.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW one of the problems with single quotes is there seems to be no accepted way of handling them. Some parsers seem to treat them as equivalent to double quotes (meaning they need to be escaped) and others treat them as just a character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apapirovski I wrote this with the RFC 4180 specs in mind. If a parser does something else (and many do), then that is just tough luck. Creating CSV files that work in all parsers is a very big challenge. We just need to make sure it works with
read.csv
inR
.