mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-27 17:53:57 +00:00
some go-benchmark files for Mac/Linux perf comparisons
This commit is contained in:
parent
c1dcdd652c
commit
fe439d04ec
5 changed files with 120 additions and 6 deletions
17
Makefile
17
Makefile
|
|
@ -31,15 +31,22 @@ install: build
|
|||
unit-test ut:
|
||||
go test github.com/johnkerl/miller/internal/pkg/...
|
||||
|
||||
lib-ut:
|
||||
ut-lib:
|
||||
go test github.com/johnkerl/miller/internal/pkg/lib...
|
||||
mv-ut:
|
||||
ut-mlv:
|
||||
go test github.com/johnkerl/miller/internal/pkg/mlrval/...
|
||||
bifs-ut:
|
||||
ut-bifs:
|
||||
go test github.com/johnkerl/miller/internal/pkg/bifs/...
|
||||
input-ut:
|
||||
ut-input:
|
||||
go test github.com/johnkerl/miller/internal/pkg/input/...
|
||||
|
||||
bench:
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/internal/pkg/...
|
||||
bench-mlv:
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/internal/pkg/mlrval/...
|
||||
bench-input:
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/internal/pkg/input/...
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Regression tests (large number)
|
||||
#
|
||||
|
|
@ -102,4 +109,4 @@ release_tarball: build check
|
|||
|
||||
# ================================================================
|
||||
# Go does its own dependency management, outside of make.
|
||||
.PHONY: build mlr check unit_test regression_test fmt staticcheck dev docs
|
||||
.PHONY: build mlr check unit_test regression_test bench fmt staticcheck dev docs
|
||||
|
|
|
|||
71
internal/pkg/input/record_reader_benchmark_test.go
Normal file
71
internal/pkg/input/record_reader_benchmark_test.go
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
package input
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/cli"
|
||||
)
|
||||
|
||||
// go test -run=nonesuch -bench=. github.com/johnkerl/miller/internal/pkg/input/...
|
||||
|
||||
func BenchmarkDKVPParse(b *testing.B) {
|
||||
readerOptions := &cli.TReaderOptions{
|
||||
InputFileFormat: "dkvp",
|
||||
IFS: ",",
|
||||
IPS: "=",
|
||||
IRS: "\n",
|
||||
}
|
||||
reader, err := NewRecordReaderDKVP(readerOptions, 1)
|
||||
assert.Nil(b, err)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, _ = recordFromDKVPLine(
|
||||
reader,
|
||||
"color=yellow,shape=triangle,flag=true,k=1,index=11,quantity=43.6498,rate=9.8870",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNIDXParse(b *testing.B) {
|
||||
readerOptions := &cli.TReaderOptions{
|
||||
InputFileFormat: "nidx",
|
||||
IFS: " ",
|
||||
AllowRepeatIFS: true,
|
||||
IRS: "\n",
|
||||
}
|
||||
reader, err := NewRecordReaderNIDX(readerOptions, 1)
|
||||
assert.Nil(b, err)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, _ = recordFromDKVPLine(
|
||||
reader,
|
||||
"yellow triangle true 1 11 43.6498 9.8870",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkXTABParse(b *testing.B) {
|
||||
readerOptions := &cli.TReaderOptions{
|
||||
InputFileFormat: "xtab",
|
||||
IPS: " ",
|
||||
IFS: "\n",
|
||||
IRS: "\n",
|
||||
}
|
||||
reader, err := NewRecordReaderXTAB(readerOptions, 1)
|
||||
assert.Nil(b, err)
|
||||
|
||||
stanza := newStanza()
|
||||
stanza.dataLines.PushBack("color yellow")
|
||||
stanza.dataLines.PushBack("shape triangle")
|
||||
stanza.dataLines.PushBack("flag true")
|
||||
stanza.dataLines.PushBack("k 1")
|
||||
stanza.dataLines.PushBack("index 11")
|
||||
stanza.dataLines.PushBack("quantity 43.6498")
|
||||
stanza.dataLines.PushBack("rate 9.8870")
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, _ = reader.recordFromXTABLines(stanza.dataLines)
|
||||
}
|
||||
}
|
||||
35
internal/pkg/mlrval/mlrval_benchmark_test.go
Normal file
35
internal/pkg/mlrval/mlrval_benchmark_test.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package mlrval
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// go test -run=nonesuch -bench=. github.com/johnkerl/miller/internal/pkg/mlrval/...
|
||||
|
||||
func BenchmarkFromDeferredType(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = FromDeferredType("123")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkInferIntFromDeferredType(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
mv := FromDeferredType("123")
|
||||
mv.Type()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkInferFloatFromDeferredType(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
mv := FromDeferredType("123.4")
|
||||
mv.Type()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkInferStringFromDeferredType(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
mv := FromDeferredType("abc")
|
||||
mv.Type()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
$color_shape = $color . $shape;
|
||||
$y = int($k) + int($index) **3 + log10(float($quantity)/float($rate));
|
||||
$y = $k + $index **3 + log10($quantity/$rate);
|
||||
|
|
|
|||
1
todo.txt
1
todo.txt
|
|
@ -14,6 +14,7 @@ PUNCHDOWN LIST
|
|||
? array/map fields: marshal as JSON_SINGLE_LINE
|
||||
|
||||
* numeric-inference perf
|
||||
o README-profiling.md re various scripts
|
||||
o https://stackoverflow.com/questions/64513411/why-is-strconv-parseuint-so-slow-compared-to-strconv-atoi
|
||||
o benchmark per se
|
||||
o reconsider TryInt/TryFloat -> maybe try number -- ?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue