Skip to content

Commit

Permalink
cmd/bench: Move statistics-related functions into separate package
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Fedorov committed Sep 19, 2022
1 parent 0732302 commit 002e481
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions cmd/bench/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/spf13/cobra"

"github.com/filecoin-project/mir"
"github.com/filecoin-project/mir/cmd/bench/stats"
"github.com/filecoin-project/mir/pkg/availability/batchdb/fakebatchdb"
"github.com/filecoin-project/mir/pkg/availability/multisigcollector"
"github.com/filecoin-project/mir/pkg/batchfetcher"
Expand Down Expand Up @@ -165,8 +166,8 @@ func runNode() error {

cryptoSystem := deploytest.NewLocalCryptoSystem("pseudo", membership.GetIDs(initialMembership), logger)

stats := NewStats()
interceptor := NewStatInterceptor(stats, "app")
stat := stats.NewStats()
interceptor := stats.NewStatInterceptor(stat, "app")

nodeModules, err := iss.DefaultModules(modules.Modules{
"net": transport,
Expand Down Expand Up @@ -212,8 +213,8 @@ func runNode() error {
statFile = os.Stdout
}

statsCSV := csv.NewWriter(statFile)
stats.WriteCSVHeader(statsCSV)
statCSV := csv.NewWriter(statFile)
stat.WriteCSVHeader(statCSV)

go func() {
timestamp := time.Now()
Expand All @@ -226,10 +227,10 @@ func runNode() error {
return
case ts := <-ticker.C:
d := ts.Sub(timestamp)
stats.WriteCSVRecord(statsCSV, d)
statsCSV.Flush()
stat.WriteCSVRecord(statCSV, d)
statCSV.Flush()
timestamp = ts
stats.Reset()
stat.Reset()
}
}
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: Apache-2.0

package cmd
package stats

import (
"github.com/filecoin-project/mir/pkg/events"
Expand Down
2 changes: 1 addition & 1 deletion cmd/bench/cmd/stats.go → cmd/bench/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: Apache-2.0

package cmd
package stats

import (
"encoding/csv"
Expand Down

0 comments on commit 002e481

Please sign in to comment.