go - write simple unit test for isolated function in golang, ethereum virtual machine -


in situation there isn't 1 correct answer, or expected result, can check for, i'm looking evaluate execution time of function under different conditions, still unit-test?


there's function embedded in project i'm working on executes addition operation (opadd) on virtual machine (the ethereum vm), file can found on project github page.

this specific function responsible task:

func opadd(pc *uint64, evm *evm, contract *contract, memory *memory, stack *stack) ([]byte, error) {     x, y := stack.pop(), stack.pop()     stack.push(math.u256(x.add(x, y)))      evm.interpreter.intpool.put(y)      return nil, nil } 

what i'd create "unit-test" of sorts evaluate execution speed of operation. assess i've modified function accordingly:

func opadd(pc *uint64, evm *evm, contract *contract, memory *memory, stack *stack) ([]byte, error) {      // begin execution time tracking     var starttime = time.now().unixnano();      x, y := stack.pop(), stack.pop()     stack.push(math.u256(x.add(x, y)))      evm.interpreter.intpool.put(y)      // log ellapsed execution time     fmt.println("execute opadd consume = ",(time.now().unixnano() - starttime))      return nil, nil } 

however, missing ability call function in isolation, , feed varying amounts of data such evaluate behaviour of code under different conditions.

for instance i'd see how long takes execute gigabytes, megabytes, etc.

there code check functioning of vm here, it's complicated me understand- i'm new golang.

what i'd write simplest program possible invoke function, taking parameter varying amount of input data process. towards end i've examined multiple resources, if experienced gopher point me in right direction immeasurably valuable advancing understanding of how construct practical unit tests.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -