Hi
I am trying to use Julia for general purpose programming.
I am trying to use Julia to create a faster version of a Perl script, which is supposed to create a report on a large logfile, piped into STDIN. The logfile does not fit into RAM, hence the data needs to be read from STDIN line-by-line from the data stream.
My problem is that Julia (1.5.3) is twice as slow as Perl.
I was able to identify one of the main problems, which is the code to read line-by-line from the input stream.
I use the following test code only to illustrate the issue.
Perl:
#!/bin/perl -w
use strict;
use warnings;
my $counter = 0;
while(<>) {
$counter++;
}
print "Perl: Number of lines: $counter\n";
Julia:
#!/bin/julia
counter = 0
for line = eachline()
global counter += 1
end
println("Julia: Number of lines: $counter")
Performance Perl:
# time (cat access.log | ./testloopspeed.pl)
Perl: Number of lines: 19567100
real 0m15.251s
user 0m10.475s
sys 0m8.209s
Performance Julia:
# time (cat access.log | ./testloopspeed.jl)
Julia: Number of lines: 19557160
real 0m36.974s
user 0m27.348s
sys 0m6.368s
During runtime of above test code, I noticed that Perl is using much less RAM.
Language | Resident-Memory | Virtual-Memory |
---|---|---|
Perl | 2,4MB | 127MB |
Julia | 185MB | 686MB |
What am I doing wrong?
Please notice, that there is another topic on a very similar subject here:
Regards
Toni