Skip to content

Instantly share code, notes, and snippets.

View samth's full-sized avatar

Sam Tobin-Hochstadt samth

View GitHub Profile
@samth
samth / http-client.rkt
Created May 31, 2012 15:40
A simple http client in Racket by p4bl0
#lang racket/base
;; By http://www.reddit.com/user/p4bl0 at http://paste.fulltxt.net/FZ4-HeULc
;; `racket -il readline -t http-client.rkt`
;; then you can use (M "/path/...") where M can be get, post, put, delete.
;; When authenticated, you can logout using (logout).
;; The host and port can be changed using set!.
(require racket/tcp
#lang typed/racket
(require typed/racket/draw
plot/private/common/parameters ;; just for plot-width, plot-height
)
(: transform-points : (Listof (List Integer Real)) -> (Listof (Pair Real Real)))
(define (transform-points p)
(define-values (min-x min-y max-x max-y)
(for/fold ([min-x : Integer (first (first points))]
#lang racket
(require sugar)
(define (go file h)
(define lines (file->lines file))
(match-define (list header chunks ... summary) (filter-split lines (lambda (l) (equal? l ""))))
(define p
(for/list ([l chunks])
(define size (regexp-match "leak of (.+) .* in (.+) object" (car l)))
(list (and size (map string->number (cdr size)))
(filter values
#lang racket
(require racket/fixnum)
(define (bignum? x) (integer? x))
(define ($bignum-length x) (quotient (integer-length x) 10))
(define (integer* x y) (* x y))
(require racket/trace)
(define-syntax-rule (assert b . args)
build-failure-explain
#hash((missing-unstable . ("pict3d-orig"))
((#f missing-module) . ("satore"))
(unknown
.
("common-icons"
"chive"
"kenney-assets"
"zaoqil"
"pretty-graphs"
#lang racket/base
(require racket/fixnum racket/unsafe/ops racket/vector)
(#%declare #:unsafe)
(define basis 2166136261)
(define prime 16777619)
(define (fnv1a bs scale)
(for/fold ([h basis])
([b (in-bytes bs)])
#lang racket/base
(require racket/string racket/bytes racket/vector racket/port)
(define h (make-hash))
;(#%declare #:unsafe)
(define (split-lines/bytes)
(for* ([l (in-bytes-lines)])
(let loop ([i 0] [last 0])
(cond [(= i (bytes-length l))
#lang racket/base
(require racket/string racket/bytes racket/vector racket/port)
(define h (make-hash))
(#%declare #:unsafe)
(define (split-lines)
(for* ([l (in-bytes-lines)])
(let loop ([i 0] [last 0])
(cond [(= i (bytes-length l))
@samth
samth / 206-vs-80.md
Last active February 25, 2021 16:44
Racket performance improvement over 17 years

Arseny Kapoulkine (h/t John Regehr) wrote a nice exploration of how LLVM from 2010 compares to the performance we get today. I decided to try out an old version of Racket, and compare performance to a modern version.

The versions I compared were:

  • MzScheme 206p1, released January 2004
  • Racket 8.0.0.4, compiled February 2021 (using the Chez Scheme backend)

I measured exactly one benchmark, a mandelbrot set computation from the Computer Language Benchmarks Game, using the implementation in the Racket repository. Of course, that code won't run on v206p1, so I modified it to avoid new features of Racket. The modified version is below.

Of course, many of the features that have been added make the program faster, so it's important to compare with the performance of the modern code. There's even a [parallel version](https://githu

631 [warning] Implementation of identifier unsafe-undefined not found in module #%unsafe!
544 [warning] Implementation of identifier #%variable-reference not found in module #%core!
544 [warning] Implementation of identifier variable-reference-from-unsafe? not found in module #%linklet-primitive!
109 [warning] Implementation of identifier fx+ not found in module #%flfxnum!
88 [warning] Implementation of identifier prop:authentic not found in module #%runtime!
80 [warning] Implementation of identifier primitive-table not found in module #%linklet-primitive!
73 [warning] Implementation of identifier unsafe-place-local-ref not found in module #%unsafe!
40 [warning] Implementation of identifier unsafe-place-local-set! not found in module #%unsafe!
39 [warning] Implementation of identifier vector*-ref not found in module #%runtime!
38 [warning] Implementation of identifier eof-object? not found in module #%runtime!