The benchmark is done by running the following codes:
max_size
: 10.000, 100.000, and 1.000.000The result (find nth prime number using Sieve of Eratosthenes):
Max Size | Running Time (s) Dinfio 3.1.04 |
Running Time (s) Dinfio 3.1.03 |
Memory Usage (MB) Dinfio 3.1.04 |
Memory Usage (MB) Dinfio 3.1.03 |
---|---|---|---|---|
10k | 0.005 | 0.011 | 1.2 | 1.9 |
100k | 0.032 | 0.14 | 8.9 | 14.5 |
1M | 0.34 | 1.86 | 82.9 | 141.3 |
The result (linear search):
Total Data | Running Time (s) Dinfio 3.1.04 |
Running Time (s) Dinfio 3.1.03 |
Memory Usage (MB) Dinfio 3.1.04 |
Memory Usage (MB) Dinfio 3.1.03 |
---|---|---|---|---|
10k | 0.011 | 0.013 | 0.7 | 4.4 |
100k | 0.081 | 0.124 | 7.9 | 43.9 |
1M | 0.786 | 1.505 | 78.3 | 437.2 |
Code (find nth prime number using Sieve of Eratosthenes):
' nth Prime Number using Sieve of Eratosthenes
start
max_size = 1000000
nth = 10
primes = []
is_prime = []
sieve_of_eratosthenes()
writeln(nth & "th prime number is " & primes[nth - 1])
stop
function sieve_of_eratosthenes()
for i, 0, max_size
is_prime[i] = true
endfor
p = 2
while p * p < max_size
if is_prime[p]
for i, p * p, max_size - 1, p
is_prime[i] = false
endfor
endif
p += 1
endwhile
for p, 2, max_size - 1
if is_prime[p]
append(primes, p)
endif
endfor
stop
Code (linear search):
' Linear search
import fileio
data = []
key = "1000000"
found = false
' Read data from file
f = file("data-" & key & ".txt", file_read)
while !f.eof()
append(data, f.readln())
endwhile
' Search the key
for i, 0, size(data) - 1
if key == data[i]
found = true
break
endif
endfor
writeln(found)
Data: linear-search-data.zip.
The benchmark is done by running a linear search with total data: 1.000, 10.000, 100.000, and 1.000.000. The key is located at the end of the data.
System: MacBook Air Early 2015, Core i5-5250U 1.6 GHz Dual Core, 8 GB DDR3 RAM, macOS 10.14.5.
The result:
Total Data | Running Time (s) Dinfio 3.1.01 |
Running Time (s) Dinfio 3.1.0 |
---|---|---|
1k | 0.005 | 0.011 |
10k | 0.019 | 0.053 |
100k | 0.195 | 0.521 |
1M | 2.231 | 5.544 |
Code:
import fileio
data = []
key = "1000000"
found = false
' Read data from file
f = file("data-" & key & ".txt", file_read)
while !f.eof()
append(data, f.readln())
endwhile
' Search the key
for i, 0, size(data) - 1
if key == data[i]
found = true
break
endif
endfor
writeln(found)
Data: linear-search-data.zip.
The benchmark is done by running a loop of variable assignment 1.000.000, 10.000.000, and 100.000.000 times. Performance is compared to Dinfio 3.0.12.
System: Core i7-8565U 1.8 GHz Quad Core, 8 GB DDR4 RAM, Windows 10.
The result:
Loop Times | Running Time (s) Dinfio 3.1.0 |
Running Time (s) Dinfio 3.0.12 |
---|---|---|
1M | 0.031 | 0.82 |
10M | 0.28 | 4.16 |
100M | 2.67 | 28.82 |
Code 1:
n = 1000000
for i, 1, n
a = i
endfor
Code 2:
n = 10000000
for i, 1, n
a = i
endfor
Code 3:
n = 100000000
for i, 1, n
a = i
endfor