aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-08-09 14:26:15 +0200
committerRon Evans <[email protected]>2021-08-12 13:23:41 +0200
commitc25a7cc7477a5fc58d68e125ec2cf62836f23fe2 (patch)
treeee6f2a1c76048becff3d00a6bdeb9542d0475187 /tests
parent5e5ce98d42f56336779f7969437892cf2df2eabd (diff)
downloadtinygo-c25a7cc7477a5fc58d68e125ec2cf62836f23fe2.tar.gz
tinygo-c25a7cc7477a5fc58d68e125ec2cf62836f23fe2.zip
testing: test testing package using `tinygo test`
Diffstat (limited to 'tests')
-rw-r--r--tests/tinygotest/benchmark_test.go50
1 files changed, 0 insertions, 50 deletions
diff --git a/tests/tinygotest/benchmark_test.go b/tests/tinygotest/benchmark_test.go
deleted file mode 100644
index c045c975b..000000000
--- a/tests/tinygotest/benchmark_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package testbench
-
-import (
- "testing"
-)
-
-var buf = make([]byte, 13579)
-
-func NonASCII(b []byte, i int, offset int) int {
- for i = offset; i < len(b) + offset; i++ {
- if b[i % len(b)] >= 0x80 {
- break
- }
- }
- return i
-}
-
-func BenchmarkFastNonASCII(b *testing.B) {
- var val int
- for i := 0; i < b.N; i++ {
- val += NonASCII(buf, 0, 0)
- }
-}
-
-func BenchmarkSlowNonASCII(b *testing.B) {
- var val int
- for i := 0; i < b.N; i++ {
- val += NonASCII(buf, 0, 0)
- val += NonASCII(buf, 0, 1)
- }
-}
-
-// TestBenchmark simply uses Benchmark twice and makes sure it does not crash.
-func TestBenchmark(t *testing.T) {
- // FIXME: reduce runtime from the current 3 seconds.
- rslow := testing.Benchmark(BenchmarkSlowNonASCII)
- rfast := testing.Benchmark(BenchmarkFastNonASCII)
- tslow := rslow.NsPerOp()
- tfast := rfast.NsPerOp()
-
- // Be exceedingly forgiving; do not fail even if system gets busy.
- speedup := float64(tslow) / float64(tfast)
- if speedup < 0.3 {
- t.Errorf("Expected speedup >= 0.3, got %f", speedup)
- }
-}