Skip to content

Instantly share code, notes, and snippets.

@ktakashi
Created February 7, 2018 13:46
Show Gist options
  • Save ktakashi/21fa4778e79a413240a80700ebd42eaf to your computer and use it in GitHub Desktop.
Save ktakashi/21fa4778e79a413240a80700ebd42eaf to your computer and use it in GitHub Desktop.
TLS benchmark
#!read-macro=sagittarius/bv-string
(import (rnrs)
(time)
(sagittarius control)
(sagittarius socket)
(rfc tls))
(define *poor-victim* "www.google.com")
(define iteration 100)
(let ((sock (make-client-tls-socket *poor-victim* "443"))
(buf (make-bytevector 1024)))
(time (dotimes (i iteration)
(tls-socket-send sock #*"GET / HTTP/1.1\r\n\r\n")
(tls-socket-recv! sock buf 0 1024)))
(tls-socket-shutdown sock SHUT_RDWR)
(tls-socket-close sock))
$ SAGITTARIUS_CACHE_DIR=/tmp sash bench.scm
;; (dotimes (i iteration) (tls-socket-send sock #vu8(71 69 84 32 47 32 72 84 84 80 47 49 46 49 13 10 13 10)) (tls-socket-recv! sock buf 0 1024))
;; 1.847038 real 0.008000 user 0.008000 sys
$ SAGITTARIUS_CACHE_DIR=/tmp SCHEME_ENV_REPOSITORY=~/projects/scheme-env scheme-env run bench.scm
;; (dotimes (i iteration) (tls-socket-send sock #vu8(71 69 84 32 47 32 72 84 84 80 47 49 46 49 13 10 13 10)) (tls-socket-recv! sock buf 0 1024))
;; 1.989803 real 0.064000 user 0.000000 sys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment