提交 fc3e01bb 编写于 作者: A aarzilli 提交者: Derek Parker

tests: add benchmark for conditional breakpoints

上级 279c29a3
package main
import (
"fmt"
"time"
)
func main() {
sum := int64(0)
start := time.Now()
for value := int64(0); value < 10000; value++ {
sum += value
}
elapsed := time.Since(start)
fmt.Printf("Sum: %d\nTook %s\n", sum, elapsed)
}
......@@ -190,7 +190,7 @@ func setFunctionBreakpoint(p *proc.Target, t testing.TB, fname string) *proc.Bre
return bp
}
func setFileBreakpoint(p *proc.Target, t *testing.T, path string, lineno int) *proc.Breakpoint {
func setFileBreakpoint(p *proc.Target, t testing.TB, path string, lineno int) *proc.Breakpoint {
_, f, l, _ := runtime.Caller(1)
f = filepath.Base(f)
......@@ -4557,3 +4557,19 @@ func TestIssue1795(t *testing.T) {
}
})
}
func BenchmarkConditionalBreakpoints(b *testing.B) {
b.N = 1
withTestProcess("issue1549", b, func(p *proc.Target, fixture protest.Fixture) {
bp := setFileBreakpoint(p, b, fixture.Source, 12)
bp.Cond = &ast.BinaryExpr{
Op: token.EQL,
X: &ast.Ident{Name: "value"},
Y: &ast.BasicLit{Kind: token.INT, Value: "-1"},
}
err := proc.Continue(p)
if _, exited := err.(proc.ErrProcessExited); !exited {
b.Fatalf("Unexpected error on Continue(): %v", err)
}
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册