Created
February 1, 2018 18:33
-
-
Save xeoncross/15c5a135352ec1ed76145875dffd86b5 to your computer and use it in GitHub Desktop.
Generate as many stellar keypairs as possible for a benchmark.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"runtime" | |
"sync" | |
"sync/atomic" | |
"time" | |
"github.com/stellar/go/keypair" | |
) | |
var ops uint32 | |
func main() { | |
cpus := runtime.NumCPU() | |
fmt.Printf("Starting %d workers\n\n", cpus) | |
go func() { | |
for { | |
<-time.After(1 * time.Second) | |
log.Println(atomic.LoadUint32(&ops)) | |
atomic.StoreUint32(&ops, 0) | |
} | |
}() | |
var wg sync.WaitGroup | |
wg.Add(1) | |
for i := 0; i < cpus; i++ { | |
go func() { | |
for { | |
atomic.AddUint32(&ops, 1) | |
pair, err := keypair.Random() | |
if err != nil { | |
panic(err) | |
} | |
pair.Address() // Public Key in string form | |
} | |
}() | |
} | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
go get
to installgithub.com/stellar/go
go run generate_stellar_keys.go