Skip to content

Commit

Permalink
chore: Add cpu-cycle-overrun1.txtar . See the PR.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
  • Loading branch information
jefft0 committed Mar 5, 2024
1 parent 27c5a65 commit 57953f1
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions gno.land/cmd/gnoland/testdata/cpu-cycle-overrun1.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
loadpkg gno.land/p/demo/avl

# start a new node
gnoland start

gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/cpu_cycle_overrun1 -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# Call AddData 8 times
gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# Call AddData one more time. The call the Render hangs. If you comment this out, then the call to Render returns quickly.
gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# Call Render
gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func Render -gas-fee 1ugnot -gas-wanted 100000000 -args '' -broadcast -chainid=tendermint_test test1
stdout OK!

-- cpu_cycle_overrun1.gno --
package cpu_cycle_overrun1

import (
"strconv"
"time"

"gno.land/p/demo/avl"
)

var gData = avl.Tree{} // id -> string

type MyData struct {
data avl.Tree
}

// Add a lot of data to gData (as much as we can do with the given maximum gas allowed).
func AddData() {
for i := 1; i <= 150; i++ {
gData.Set(strconv.Itoa(gData.Size()), "hello")
}
}

func Render(path string) string {
// Put the data in allData.
subdata := &MyData{data: gData}
allData := avl.Tree{}
gData.Iterate("", "", func(key string, postI interface{}) bool {
allData.Set(strconv.Itoa(allData.Size()), subdata)
return false
})

// Iterate allData and make the render string.
now := time.Now()
str := ""
allData.Iterate("", "", func(key string, dataI interface{}) bool {
str += now.Format("2006-01-02 3:04pm MST")
return false
})
return "len " + strconv.Itoa(len(str))
}

0 comments on commit 57953f1

Please sign in to comment.