-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates for the write-100mb benchmark
* Add a Racket implementation. * Add README.rst with current results on my machine and a note about Unicode. * Write 100x more data to get a stronger signal and amortize startup costs. I want to run these all as executables so I can do the timing the same way, with the `time` command. Dylan has faster startup times, so we could argue whether that's fair, but we'll worry about that when Dylan's times get good enough for that to matter.
- Loading branch information
Showing
5 changed files
with
51 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Write 10_000MB, best of three runs on an Apple M3 Pro, May 2024: | ||
|
||
Python SBCL Dylan Racket | ||
real 7.500s 13.837s 23.425s 30.620s | ||
1.0x 1.8x 3.1x 4.1x | ||
user 4.837s 11.334s 6.455s 21.053s | ||
1.0x 2.3x 1.3x 4.4x | ||
sys 2.286s 2.368s 10.749s 7.031s | ||
|
||
|
||
Note that the other implementations are using Unicode so comparison isn't | ||
really fair. In particular, Racket does better than SBCL if the test is changed | ||
to use a byte string (#"xxx") but has a particularly pessimized Unicode path, | ||
it seems. |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
(in-package :cl-user) | ||
|
||
(defun write-100mb () | ||
(defun write-10000mb () | ||
;; (declare (optimize (speed 3) (debug 0))) | ||
(let ((string (make-string 100 :initial-element #\x))) | ||
(with-open-file (stream "/tmp/100mb.sbcl.txt" :direction :output :if-exists :supersede) | ||
(loop repeat (* 1024 1024) | ||
do (write-string string stream))))) | ||
(loop repeat 100 | ||
do (with-open-file (stream "/tmp/100mb.sbcl.txt" :direction :output :if-exists :supersede) | ||
(loop repeat (* 1024 1024) | ||
do (write-string string stream)))))) | ||
|
||
(write-100mb) | ||
;;; sbcl --noinform --no-sysinit --no-userinit --eval '(load "write-100mb.lisp")' --eval '(sb-ext:save-lisp-and-die #P"/tmp/clwrite100mb" :executable t :toplevel 'cl-user::write-10000mb)' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#lang racket/base | ||
|
||
(require racket/port) | ||
|
||
(define (write-10000mb) | ||
;; Use #"xxx" to write a byte string instead. MUCH faster. | ||
(let ((string "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")) | ||
(let outer ((o 100)) | ||
(when (> o 0) | ||
(call-with-output-file | ||
#:exists 'truncate | ||
"/tmp/100mb.racket.txt" | ||
(lambda (port) | ||
(let loop ((n (* 1024 1024))) | ||
(when (> n 0) | ||
(display string port) | ||
(loop (- n 1)))))) | ||
(outer (- o 1)))))) | ||
|
||
(write-10000mb) |
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