Skip to content

Instantly share code, notes, and snippets.

@samth
Created October 8, 2019 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samth/2c84e31f602b9ad95331a7e29b075294 to your computer and use it in GitHub Desktop.
Save samth/2c84e31f602b9ad95331a7e29b075294 to your computer and use it in GitHub Desktop.
#lang racket/base
(define N 10000000)
(unless (fixnum? (* 100 N)) (error 'fail))
(require futures-sort racket/fixnum racket/vector)
(define fxv (for/fxvector #:length N
([_ (in-range N)])
(random (* 10 N))))
(define fxv2 (fxvector-copy fxv))
(define v (for/vector #:length N
([_ (in-range N)])
(random (* 10 N))))
(define v2 (vector-copy v))
(define v3 (vector-copy v))
(collect-garbage)
(define (try k)
(collect-garbage)
(define fxv (fxvector-copy fxv2))
(parameterize ([futures-sort-parallel-depth k])
(printf "k: ~s\n" k)
(time (fxvector-futures-sort! fxv))))
(define (tryv k)
(collect-garbage)
(define v (vector-copy v2))
(parameterize ([futures-sort-parallel-depth k])
(printf "k: ~s\n" k)
(time (vector-futures-sort! v))))
(try 0)
(try 1)
(try 2)
(try 3)
(try 4)
(try 8)
(try 16)
(tryv 0)
(tryv 1)
(tryv 2)
(tryv 3)
(tryv 4)
(tryv 8)
(tryv 16)
'classic
(time (vector-sort! v3 <))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment