Skip to content

Instantly share code, notes, and snippets.

@bennn
Created July 15, 2016 17:28
Show Gist options
  • Save bennn/48046d884507ec5d8804a16e2f0cd5a7 to your computer and use it in GitHub Desktop.
Save bennn/48046d884507ec5d8804a16e2f0cd5a7 to your computer and use it in GitHub Desktop.
#lang racket/base
;; Repeatedly passes an object through a simple type boundary.
(define OPAQUE-TIME 1)
(define ITERS 30000)
(module t typed/racket/base
(require typed/racket/class)
(define-type C% (Class (f (-> C C))))
(define-type C (Instance C%))
(: c% (Class (f (-> C% C%))))
(define c%
(class object%
(super-new)
(define/public (f x) x)))
(: id (-> C C))
(define (id x) x)
(define c (new c%))
(provide id c))
(module u racket/base
(require (submod ".." t) racket/contract)
(define (main N)
(for/fold ([c c])
([i (in-range N)])
(id c)))
(provide main))
(require 'u)
(let ()
(for ((i (in-range 5)))
(printf "~a iters\n" (* i ITERS))
(collect-garbage 'major)
(time (void (main (* i ITERS)))))
#;(unless (< (current-memory-use) 40000000)
(raise-user-error 'object/c-opaque "Unusually high memory use, stronger? check may not be working")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment