New benchmark strategy: Loop indefinitely for a fixed amount of CPU time

master
Ivan Zahariev 2016-09-06 23:47:58 +03:00
parent fa27bca082
commit 97519e06e5
9 changed files with 9 additions and 9 deletions

View File

@ -86,7 +86,7 @@ class IntList {
class PrimeNumbersBenchmarkApp {
public static void main(String[] args) {
IntList res;
for (int i = 1; i <= 10; ++i) {
while (true) {
res = (new PrimeNumbersGenerator()).get_primes7(10000000);
System.out.format("Found %d prime numbers.\n", res.size());
}

View File

@ -59,7 +59,7 @@ void get_primes7(int n, vector<int> &res) {
}
int main() {
for (int i = 1; i <= 10; ++i) {
while (1) {
vector<int> res;
get_primes7(10000000, res);
printf("Found %d prime numbers.\n", (int)res.size());

View File

@ -48,7 +48,7 @@ func getPrimes7(n int) []int {
func main() {
var res []int
for i := 0; i < 10; i++ {
for {
res = getPrimes7(10000000)
fmt.Printf("Found %d prime numbers.\n", len(res))
}

View File

@ -44,7 +44,7 @@ class PrimeNumbersGenerator {
class PrimeNumbersBenchmarkApp {
public static void main(String[] args) {
ArrayList<Integer> res;
for (int i = 1; i <= 10; ++i) {
while (true) {
res = (new PrimeNumbersGenerator()).get_primes7(10000000);
System.out.format("Found %d prime numbers.\n", res.size());
}

View File

@ -34,7 +34,7 @@ function get_primes7(n) {
return res;
}
for (var i = 0; i < 10; i++) {
while (1) {
var res = get_primes7(10000000);
console.log("Found " + res.length + " prime numbers.");
}

View File

@ -32,7 +32,7 @@ function get_primes7($n) {
}
$res = array();
for ($i = 1; $i <= 10; ++$i) {
while (1) {
$res = get_primes7(10000000);
print "Found ".count($res)." prime numbers.\n";
}

View File

@ -36,7 +36,7 @@ sub get_primes7($) {
}
my @res;
for (1..10) {
while (1) {
@res = get_primes7(10000000);
print "Found ".(scalar @res)." prime numbers.\n";
}

View File

@ -28,6 +28,6 @@ def get_primes7(n):
m = 2*i+3
return [2]+[x for x in s if x]
for t in range(10):
while True:
res = get_primes7(10000000)
print("Found {} prime numbers.".format(len(res)))

View File

@ -24,7 +24,7 @@ def get_primes7(n)
[2] + s.compact
end
10.times do
loop do
res = get_primes7(10000000)
puts "Found #{res.length} prime numbers."
end