Created
October 6, 2019 01:41
-
-
Save samth/72e80e42dc1d799b59221577ec008c3c to your computer and use it in GitHub Desktop.
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
#lang racket/base | |
(require racket/future) | |
(define N 100000000) | |
(define v (for/vector #:length N ([i N]) i)) | |
(define (sum-vec v) | |
(for/sum ([i (in-vector v)]) i)) | |
;(time (+ (sum-vec v) (sum-vec v))) | |
(define t1 (current-process-milliseconds)) | |
(time (let ([n1 (future (lambda () (sum-vec v)))] | |
[n2 (sum-vec v)]) | |
(+ (touch n1) n2))) | |
(define t2 (current-process-milliseconds)) | |
(- t2 t1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment