Skip to content

Commit

Permalink
make exported json keys compatible with that of hyperfine
Browse files Browse the repository at this point in the history
  • Loading branch information
shravanasati committed Mar 30, 2024
1 parent a34e1fa commit fdbe807
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ Renders assistance for *atomic* on a terminal, briefly showing its usage.

## Acknowledgement

This tool is heavily inspired by [*hyperfine*](https://github.com/sharkdp/hyperfine). I learnt a lot of stuff looking at the code of this project and tried matching it as close as possible.
This tool is heavily inspired by [*hyperfine*](https://github.com/sharkdp/hyperfine). I learnt a lot of stuff looking at the code of this project and tried matching the feature-set as close as possible.

## Known Issues and Missing Features

- [ ] Shell calibration yields negative process run times
- [ ] No Color functionality is broken
- [ ] Implementation of errorbar, boxplot and bubble chart is pending
- [ ] Plot command is missing

## 🔖 Versioning
*atomic* releases follow semantic versioning, every release is in the *x.y.z* form, where:
Expand Down
1 change: 0 additions & 1 deletion internal/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func Export(formats []string, filename string, results []*SpeedResult, timeUnit
for _, format := range formats {
switch format {
case "json":
// todo make the json tags hyperfine output compatible
jsonMap := map[string]any{"time_unit": timeUnit.String()[1:], "results": results}
jsonData, err := jsonify(jsonMap)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import "time"
// Contains all the numerical quantities (in microseconds) for relative speed comparison. Also used for export.
type SpeedResult struct {
Command string `json:"command,omitempty"`
AverageElapsed float64 `json:"average_elapsed,omitempty"`
AverageUser float64 `json:"average_user,omitempty"`
AverageSystem float64 `json:"average_system,omitempty"`
StandardDeviation float64 `json:"standard_deviation,omitempty"`
AverageElapsed float64 `json:"mean,omitempty"`
AverageUser float64 `json:"user,omitempty"`
AverageSystem float64 `json:"system,omitempty"`
StandardDeviation float64 `json:"stddev,omitempty"`
Max float64 `json:"max,omitempty"`
Min float64 `json:"min,omitempty"`
Times []float64 `json:"times,omitempty"`
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"strings"
"time"

"github.com/shravanasati/atomic/internal"
"github.com/shravanasati/commando"
"github.com/google/shlex"
"github.com/mitchellh/colorstring"
"github.com/schollz/progressbar/v3"
"github.com/shravanasati/atomic/internal"
"github.com/shravanasati/commando"
)

const (
Expand Down Expand Up @@ -509,7 +509,7 @@ func main() {
SetAction(func(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) {
// * getting args and flag values
if strings.TrimSpace(args["commands"].Value) == "" {
internal.Log("red", "error: not enough arguments.")
internal.Log("red", "error: not enough arguments. try running `atomic --help`.")
return
}
runs, e := flags["runs"].GetInt()
Expand Down Expand Up @@ -818,7 +818,7 @@ func main() {
}

internal.RelativeSummary(speedResults)

// modify speedResults to convert values from microseconds to timeUnit
// if and only if either export or plotting needs to be done
if exportFormatString != "none" || plotString != "none" {
Expand Down

0 comments on commit fdbe807

Please sign in to comment.