-
-
Notifications
You must be signed in to change notification settings - Fork 691
Fast Racket
The performance of Racket programs is usually faster than equivalent Python programs and compares favourably with other languages in the same category. For mode details see The Computer Language Benchmarks Game page.
The performance of an individual program will depend both on the chosen algorithms data structures and the Racket environment in which it is run:
- Run your program using
racket. Non-interactive mode should be used instead of the REPL to benefit from the module system. - Consider creating an executable to reduce startup time.
- if your program uses a lot of mathematical calculation, consider using Typed Racket.
- Consider using Typed Racket if your application uses a lot of mathematical calculation
- Consider using
futuresfor parts of your application that are parallelizable. - use the FFI to run for performance sensitive parts of your application in C or C++. e.g. flomat lets you call out to BLAS and LAPACK from standard Racket.
When writing your program
-
make use of the profiler in DrRacket to better understand the performance of your code.
-
make DrRacket to perform more like
racketby using theChoose Language...dialogShow Detailspanel to;- disable debugging & profiling
- disable
Preserve stacktrace(checkbox)
-
Profile parallel programs written using
future's using thefutures visualizergraphical profiling tool.
When evaluating the performance of your own Racket programs please be aware of the following caveats:
- Student Languages are aimed at providing help for students and have extra debugging enabled. Port your code to '#lang racket' for a speed boost.
- Programs run inside DrRacket, have debugging enabled by default. This will provide better error reporting, but programs will run slower.
Here are a few tips for ensuring your Racket programs run fast:
- choose an appropriate algorithm and data structure for your program.
- run your program using racket (not inside the DrRacket IDE).
- if the startup time is important consider compiling your program and creating an executable.
- if your program uses a lot of mathematical calculation, consider using Typed Racket.
- Racket provides a FFI interface and you can write performance sensitive parts of your application in C or C++ -- this is the approach that Python takes with their numpy and scipy libraries.
For more details on Racket Performance, Virtual Machine Implementations, byte code, machine code, and Just-in-Time (JIT) Compilers see the Performance Chapter in the Racket Guide.
