Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Created February 1, 2018 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeoncross/15c5a135352ec1ed76145875dffd86b5 to your computer and use it in GitHub Desktop.
Save xeoncross/15c5a135352ec1ed76145875dffd86b5 to your computer and use it in GitHub Desktop.
Generate as many stellar keypairs as possible for a benchmark.
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()
}
@xeoncross
Copy link
Author

  1. Checkout this file
  2. go get to install github.com/stellar/go
  3. go run generate_stellar_keys.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment