/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this Racket program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
500,0001.641.6537,632262  0% 1% 1% 100%
5,000,00014.5214.5341,164262  0% 1% 1% 100%
50,000,000144.21144.3287,148262  0% 0% 1% 100%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read thread-ring benchmark to see what this program should do.

 notes

Welcome to Racket v6.0.

 thread-ring Racket program source code

#lang racket/base

;;; The Computer Language Benchmarks Game
;;; http://benchmarksgame.alioth.debian.org/

;;; contributed by Matthew Flatt

;; Uses Racket threads

(require racket/cmdline)

;; Each thread runs this loop:
(define (run id next)
  (let ([v (thread-receive)])
    (cond
     [(zero? v) ;; Done
      (printf "~a\n" id)
      (exit)]
     [else ;; Keep going
      (thread-send next (sub1 v))
      (run id next)])))
                       

(let ([n (command-line #:args (n) (string->number n))])
  ;; The original thread is #503. Create the rest:
  (let ([t1 (for/fold ([next (current-thread)])
                      ([id (in-range 502 0 -1)])
              (thread (lambda () (run id next))))])
    ;; Start:
    (thread-send t1 n)
    (run 503 t1)))

 make, command-line, and program output logs

Fri, 28 Feb 2014 11:00:48 GMT

COMMAND LINE:
/usr/local/src/racket-6.0/bin/racket  threadring.racket 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play