BF:BFD[
6.9] → [
4.246:271]
BF:BFD[
4.271] → [
6.27:27]
B:BD[
6.569] → [
6.569:1221]
∅:D[
3.35] → [
6.1389:1497]
B:BD[
6.1389] → [
6.1389:1497]
∅:D[
3.226] → [
6.1625:1677]
B:BD[
6.1625] → [
6.1625:1677]
∅:D[
3.337] → [
6.1677:1682]
B:BD[
6.1677] → [
6.1677:1682]
B:BD[
6.1677] → [
3.227:337]
B:BD[
6.1589] → [
3.186:226]
B:BD[
6.1497] → [
3.36:185]
package primes_test
import (
"primes"
"testing"
"github.com/matryer/is"
)
var primeCases = []struct {
input int
expected []int
}{
{0, []int{}},
{1, []int{}},
{2, []int{2}},
{10, []int{2, 3, 5, 7}},
{100, []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}},
}
var sieveCases = []struct {
input int
expected []bool
}{
// every non-prime is true, 0-th and 1-st is false, should be true
{0, []bool{false}},
{1, []bool{false, false}},
{2, []bool{false, false, false}},
{100, []bool{false, false, false, false, true, false, true, false, true, true, true, false, true, false, true, true, true, false, true, false, true, true, true, false, true, true, true, true, true, false, true, false, true, true, true, true, true, false, true, true, true, false, true, false, true, true, true, false, true, true, true, true, true, false, true, true, true, true, true, false, true, false, true, true, true, true, true, false, true, true, true, false, true, false, true, true, true, true, true, false, true, true, true, false, true, true, true, true, true, false, true, true, true, true, true, true, true, false, true, true, true}},
}
is := is.New(t)
for _, tc := range sieveCases {
is.Equal(tc.expected, primes.JustSieve(tc.input))
}
}
for i := 0; i < b.N; i++ {
primes.JustSieve(1e6)
}
}
}
}
func BenchmarkConcurrentSieve(b *testing.B) {
for i := 0; i < b.N; i++ {
primes.ConcurrentSieve(1e6)
func BenchmarkJustSieve(b *testing.B) {
func TestConcSieve(t *testing.T) {
is := is.New(t)
for _, tc := range sieveCases {
is.Equal(tc.expected, primes.ConcurrentSieve(tc.input))
}
}
func TestJustSieve(t *testing.T) {
{10, []bool{false, false, false, false, true, false, true, false, true, true, true}},