Created
August 23, 2015 17:47
-
-
Save ufechner7/39124402f17eee3f40a8 to your computer and use it in GitHub Desktop.
Test script for the realtime performance of Julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Winston | |
const SIMUL_DUR = 10.0 # simulation time in seconds | |
const PeriodTime = 20e-3 # period time for the simulation in seconds | |
const workload = 20000 # workload in vector additions/ multiplications per simulation step | |
const vec_size = 3 | |
const cpu_usage = zeros(round(Int, SIMUL_DUR / PeriodTime)) # data array to log the cpu usage | |
const vec = zeros(vec_size, workload) # preallocate data array of 3D vectors | |
function step(step) | |
# sleep until the next simulation interval starts | |
while abs(mod(time(), PeriodTime)) > 1e-3 | |
sleep(0.001) | |
end | |
tic(); | |
for i in 1:workload # do some work | |
vec[:,i] += ones(vec_size) | |
vec[:,i] *= 2.2 | |
end | |
cpu_usage[step] = toq() / PeriodTime; | |
end | |
function main() | |
step(1) # precompile the function step | |
step(2) # start the garbage collector | |
for i in 1:round(Int, SIMUL_DUR / PeriodTime) | |
step(i) | |
if mod(i, 100) == 0 | |
println("Steps: $i") | |
end | |
end | |
crest_factor = maximum(cpu_usage) / mean(cpu_usage) | |
min_time = minimum(cpu_usage) * PeriodTime | |
max_time = maximum(cpu_usage) * PeriodTime | |
jitter = (max_time - min_time) * 1000 | |
println("Jitter [ms]: $jitter") | |
println("Crest factor: $crest_factor") | |
plot(cpu_usage) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this test script type:
include("RealTime.jl")
main()