From 5503cca2bb8acd957411f5cb59b9732e2714525e Mon Sep 17 00:00:00 2001 From: Morgan Date: Mon, 16 Sep 2024 13:06:16 +0200 Subject: [PATCH] test(gnovm): run initStaticBlocks in BenchmarkPreprocess (#2792) fixes #2711 The bug in the benchmark was introduced in #2418, which requires to run initStaticBlocks before running Preprocess, in most cases. (in normal scenarios, this is run by PredefineFileSet; however this benchmark is deep into the internals). Related: #2716. cc/ @sw360cab
Contributors' checklist... - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
--- gnovm/pkg/gnolang/gno_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gnovm/pkg/gnolang/gno_test.go b/gnovm/pkg/gnolang/gno_test.go index 54d808faefc..1f83303023c 100644 --- a/gnovm/pkg/gnolang/gno_test.go +++ b/gnovm/pkg/gnolang/gno_test.go @@ -179,7 +179,7 @@ func BenchmarkIfStatement(b *testing.B) { func main() { for i:=0; i<10000; i++ { if i > 10 { - + } } }` @@ -356,6 +356,7 @@ func BenchmarkPreprocess(b *testing.B) { Inc("i"), ), )) + pn := NewPackageNode("hey", "gno.land/p/hey", nil) copies := make([]*FuncDecl, b.N) for i := 0; i < b.N; i++ { copies[i] = main.Copy().(*FuncDecl) @@ -363,6 +364,8 @@ func BenchmarkPreprocess(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { + // initStaticBlocks is always performed before a Preprocess + initStaticBlocks(nil, pn, copies[i]) main = Preprocess(nil, pkg, copies[i]).(*FuncDecl) } }