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