Skip to content

Comments

gapit: Add OutputCSV flag to benchmark (#2540).#2573

Merged
pau-baiget merged 3 commits intogoogle:masterfrom
pau-baiget:add-csv-benchmark
Feb 1, 2019
Merged

gapit: Add OutputCSV flag to benchmark (#2540).#2573
pau-baiget merged 3 commits intogoogle:masterfrom
pau-baiget:add-csv-benchmark

Conversation

@pau-baiget
Copy link
Contributor

This flag produces a single row of comma-separated data.
Also, all time information is expressed in milliseconds.

This flag produces a single row of comma-separated data.
Also, all time information is expressed in milliseconds.
w.Flush()
if verb.OutputCSV {
csvWriter := csv.NewWriter(os.Stdout)
defer csvWriter.Flush()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defer is a bit funny (and you probably don't actually want it here) but defer actually defers until the end of the current function (NOT the scope-block).
How I typically handle this is:

if verb.OutputCSV { 
   func() {
      csvWriter....
      defer csvwriter.Flush()
      ....
      ....
   } () 
 } else {
      ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Ok, didn't know that. Will change it and resubmit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is super subtle, and goes completely against all of my past experience (thanks Go)

Copy link
Contributor

@AWoloszyn AWoloszyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small nit about defer, and the presubmit is failing, other than that, looks good to me.

Copy link
Contributor

@AWoloszyn AWoloszyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to squash before commit.

@pau-baiget pau-baiget merged commit a64a587 into google:master Feb 1, 2019
@pau-baiget pau-baiget deleted the add-csv-benchmark branch February 1, 2019 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants