SSH signing
This commit is contained in:
parent
58d5c52886
commit
ffc330e901
17
main.go
17
main.go
|
@ -6,6 +6,7 @@ import (
|
|||
"io"
|
||||
"math/big"
|
||||
mrand "math/rand"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -17,11 +18,12 @@ type job struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(100)
|
||||
s1 := mrand.NewSource(time.Now().UnixMicro())
|
||||
r1 := mrand.New(s1)
|
||||
start := time.Now()
|
||||
|
||||
p, _ := prime(r1, 8096, 32)
|
||||
p, _ := prime(r1, 8096, 100)
|
||||
|
||||
finish := time.Now()
|
||||
elapsed := finish.Sub(start)
|
||||
|
@ -41,8 +43,8 @@ func prime(rand io.Reader, bits int, threads int) (p *big.Int, err error) {
|
|||
//bytes := make([]byte, (bits+7)/8)
|
||||
|
||||
//p = new(big.Int)
|
||||
jobs := make(chan job)
|
||||
results := make(chan job)
|
||||
jobs := make(chan job, 100)
|
||||
results := make(chan job, 100)
|
||||
numbers := make(chan *big.Int, 100)
|
||||
done := new(bool)
|
||||
*done = false
|
||||
|
@ -51,14 +53,17 @@ func prime(rand io.Reader, bits int, threads int) (p *big.Int, err error) {
|
|||
go worker(i, jobs, results, done)
|
||||
}
|
||||
|
||||
for i := 0; i < 4; i++ {
|
||||
fmt.Printf("Seeding and starting worker pool\n")
|
||||
for i := 0; i < 10; i++ {
|
||||
go rng(i, bits, numbers, done)
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
}
|
||||
|
||||
fmt.Printf("Starting!\n")
|
||||
for i := 0; ; i++ {
|
||||
newjob := &job{
|
||||
p: <-numbers,
|
||||
i: 10,
|
||||
i: 20,
|
||||
id: i,
|
||||
}
|
||||
|
||||
|
@ -97,7 +102,7 @@ func worker(id int, jobs <-chan job, results chan<- job, done *bool) {
|
|||
//fmt.Printf("Worker %d starting now!\n", id)
|
||||
for j := range jobs {
|
||||
j.result = j.p.ProbablyPrime(j.i)
|
||||
//fmt.Printf("Worker\t %d checked a number\n", id)
|
||||
fmt.Printf("Worker\t %d checked a number\n", id)
|
||||
if *done {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue