Skip to content

Instantly share code, notes, and snippets.

#lang racket/load
(define (memory)
(for ((i (in-range 10)))
(collect-garbage))
(define n (current-memory-use))
(for ((i (in-range 10)))
(collect-garbage))
n)
#lang racket/load
;; This performance test tries to construct lots of unrelated types
;; to stress hash-consing/interning of types
(displayln "The printouts below are designed to trick drdr into graphing them;")
(displayln "they aren't times, but memory usage.")
(define (print-memory)
(for ((i 10))
@takikawa
takikawa / gist:9219427
Created February 25, 2014 22:35
Class type expanded
-> (:type Button%)
(Class
(init (label
(U String
(Instance Bitmap%)
(List (Instance Bitmap%) String (U 'left 'top 'right 'bottom))))
(parent (Instance Area-Container<%>))
(callback
(-> (Instance Button%) (Instance Control-Event%) Any)
#:optional)
$ racket -I typed/racket
Welcome to Racket v6.0.0.2.
-> (require plot/typed)
-> plot
- : (-> (Rec g158665 (U nonrenderer renderer2d (Listof g158665)))
[#:height Integer]
[#:legend-anchor Anchor]
[#:out-file (U Path-String False Output-Port)]
[#:out-kind (U Image-File-Format 'auto)]
[#:title (U False String)]
> standard-fish
- : (-> Real
Real
[#:color String]
[#:direction (U 'left 'right)]
[#:eye-color (U False String)]
[#:open-mouth (U Boolean Real)]
pict)
#<procedure:standard-fish>
$ racket -I typed/racket
Welcome to Racket v6.0.0.2.
-> (lambda () (define x 1))
; readline-input:1:0: begin (possibly implicit): no expression after a sequence
; of internal definitions
; in: (begin (define x 1))
; [,bt for context]
-> (lambda ())
; readline-input:1.0: lambda: expected more terms starting with body expression
; at: ()
@takikawa
takikawa / vector.rkt
Created February 10, 2014 14:53
Start of typed/ffi/vector
#lang s-exp typed-racket/base-env/extra-env-lang
(begin (require (for-syntax typed-racket/rep/type-rep)
ffi/vector))
[make-u8vector (-> -Nat (make-Opaque #'u8vector?))]
[u8vector (->* '() -Byte (make-Opaque #'u8vector?))]
[u8vector? (make-pred-ty (make-Opaque #'u8vector?))]
[u8vector-length (-> (make-Opaque #'u8vector?) -Nat)]
[u8vector-ref (-> (make-Opaque #'u8vector?) -Int -Byte)]
$ racket -l errortrace -t ~/plt/racket-git/pkgs/scribble-pkgs/scribble-lib/scribble/run.rkt -- --pdf getting-started.scrbl
profiled thunk error: link: bad variable linkage;
reference to a variable that has the wrong procedure or structure-type shape
reference phase level: 0
variable module: "/home/asumu/plt/racket-git/pkgs/scribble-pkgs/scribble-lib/scribble/doclang.rkt"
variable phase: 0
reference in module: "/home/asumu/plt/racket-git/pkgs/racket-pkgs/racket-doc/scribblings/getting-started/getting-started.scrbl"
in: check-pre-part
Profiling results
-----------------
make-script: unexpected value rendered: '((font ((class "badlink")) (span ((class "indexlink")) (span ((class "RktModLink")) (span ((class "RktSym")) "metapict/color")))))
context...:
/home/asumu/plt/racket-git/pkgs/racket-pkgs/racket-index/scribblings/main/private/make-search.rkt:116:4: for-loop
/home/asumu/plt/racket-git/pkgs/racket-pkgs/racket-index/scribblings/main/private/make-search.rkt:64:0: make-script
/home/asumu/plt/racket-git/pkgs/scribble-pkgs/scribble-lib/scribble/base-render.rkt:870:4: render-content method in render%
/home/asumu/plt/racket-git/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt:1332:4: render-plain-content method in ...bble/html-render.rkt:254:2
/home/asumu/plt/racket-git/pkgs/scribble-pkgs/scribble-lib/scribble/base-render.rkt:870:4: render-content method in render%
/home/asumu/plt/racket-git/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt:1102:4: do-render-paragraph method in ...bble/html-render.rkt:254:2
/home/asumu/plt/racket-git/pkgs/sc
@takikawa
takikawa / gist:8718310
Last active August 29, 2015 13:55
Progress on type-checking mixed-type annotation lambdas
Welcome to Racket v6.0.0.1.
-> (lambda ([a : Integer] b c) (+ a 1))
- : (Integer Any Any -> Integer)
#<procedure>
-> (lambda ([a : Integer] b c #:d [d : String "foo"]) (string-append d "bar") (+ a 1))
- : (Integer Any Any [#:d String] -> Integer)
#<procedure:readline-input:3:0>