Thanks. So just for fun I came up with the following code which unfortunately doesn't work as expected:
tic(); i = 1; while i <= 50000000; i += 1; end; toc()
tic(); i = 1; debug = 0; while i <= 50000000; i += 1
if 1 == debug
println("my debug line: ", i);
end
end; toc()
# how to disable this macro before run-time?
macro mydebug(text, value)
println(text, value);
end
tic(); i = 1; debug = 0; while i <= 50000000; i += 1
@mydebug("my debug line: ", i);
end; toc()
When I run it then I get the following:
$ ./julia example.jl
elapsed time: 3.741771936 seconds
elapsed time: 4.526868245 seconds
my debug line: i
elapsed time: 3.639432751 seconds
Questions:
1. Why is it so much slower than the Perl equivalent, especially consider all the sexy julia benchmarks floating around?
2. Why does the macro on show one debug line instead of 50 million?
3. How to get the macro to display the value of i?
4. How to programmatically switch off / disable the macro during compile time / before run-time?
Thanks,
Simon