Пример #1
0
func omain() {
	f, err := os.Create("profile.out")
	if err != nil {
		log.Fatal("Cannot create profile")
	}
	pprof.StartCPUProfile(f)
	defer pprof.StopCPUProfile()

	var sieve euler.SieveHeap

	num := start
	for {
		prime := sieve.Next()
		if num == prime {
			fmt.Printf("%d\n", prime)
			break
		}

		// Divide out the prime as many times as possible.
		for num%prime == 0 {
			num /= prime
		}
	}

	// for i := 0; i < 100; i++ {
	// 	fmt.Printf("%8d\n", sieve.Next())
	// }
	bench()
}
Пример #2
0
func omain() {
	var sieve euler.SieveHeap

	for i := 0; i < 10000; i++ {
		sieve.Next()
	}
	fmt.Printf("%d\n", sieve.Next())
}
Пример #3
0
func bench() {
	var sieve euler.SieveHeap

	stop := int64(10000000)
	for {
		prime := sieve.Next()
		if prime >= stop {
			// fmt.Printf("%v\n", sieve)
			return
		}
	}
}