GithubHelp home page GithubHelp logo

raku_trivial_io_benchmark's Introduction

Raku Trivial IO Benchmarks

..just like the title says.  I saw a discussion board complaint
that Raku was incredibly slow for file IO, and the person complaining
stated that they used an early version of Perl6 (Raku) and it took 20 minutes
to read a 100MB file.

I decided to experiment with a recent Raku release to see how it
performed. The experiments were on Ubuntu MATE 20.04 on an AMD
Ryzen 5 processor, with the 100MB (really, 100_000_000 byte) file
on a traditional hard drive.

To run these tests, you need Raku installed.  If you want to run the C
tests for comparison you need GCC installed, or some other C compiler if
you want to change the compilation command. You must also put a file
named "junk.bytes" of length 100_000_000 bytes in the same directory
or else modify the files to handle different lengths. 

I also had the last ten bytes of each file print to ensure I was
reading the same amount each time.

To get a 100_000_000 file, you can take any file greater than 100_000_000
bytes in length, like "something.mp4" and then do
cat something.mp4 | head -c 100000000 > junk.bytes

Raku version:
raku --version
This is Rakudo version 2020.06 built on MoarVM version 2020.06
implementing Raku 6.d

Raku 2020.06, read one byte at a time:
time raku read_single_byte.raku
real	10m54.248s
user	10m20.586s
sys	0m33.337s

Raku 2021.10, read one byte at a time:
time raku read_single_byte.raku
real	1m26.391s
user	1m2.151s
sys	0m24.314s

Raku 2020.06, reading in 64k chunks:
time raku read_buffered.raku
real	0m0.347s
user	0m0.367s
sys	0m0.080s

Raku 2021.10, reading in 64k chunks:
time raku read_buffered.raku
real	0m0.320s
user	0m0.325s
sys	0m0.080s

Raku 2020.06, reading the whole file at once:
time raku read_slurp.raku
real	0m0.380s
user	0m0.332s
sys	0m0.134s

Raku 2021.10, reading the whole file at once:
time raku read_slurp.raku
real	0m0.282s
user	0m0.305s
sys	0m0.097s

C, reading the file one byte at a time:
gcc read_single_byte.c && time ./a.out
real	0m1.016s
user	0m0.988s
sys	0m0.028s

C, reading the file in 64k chunks:
gcc read_buffered.c && time ./a.out
real	0m0.018s
user	0m0.004s
sys	0m0.015s

Capturing the Raku startup time for Raku 2020.06:
time raku -e "say 'Hello World'"
real	0m0.235s
user	0m0.246s
sys	0m0.028s

Capturing the Raku startup time for Raku 2021.10:
time raku -e "say 'Hello World'"
real	0m0.164s
user	0m0.199s
sys	0m0.024s

Addendum 2020-07-02:
I have adjusted the Raku scripts to use an int instead of Int
for a loop counter and to do bindings instead of Scalar assignments
to cut memory allocations.  I tested it, and it has a marginal
impact on performance.  I want better performance, but
I am actually pleased overall, because a Raku novice shouldn't
need to learn these tricks to get good performance.

raku_trivial_io_benchmark's People

Contributors

michael-s avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.