Last active
August 14, 2019 03:32
-
-
Save belmarca/75360c45a61d450f29c5f85c1a9e0f58 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
(time (u8vector->uint16-0 u16)) | |
0.000004 secs real time | |
0.000005 secs cpu time (0.000004 user, 0.000001 system) | |
no collections | |
64 bytes allocated | |
no minor faults | |
no major faults | |
(time (std/misc/bytes#u8vector->uint u16)) | |
0.000004 secs real time | |
0.000005 secs cpu time (0.000005 user, 0.000000 system) | |
no collections | |
48 bytes allocated | |
no minor faults | |
no major faults | |
(time (u8vector->uint16-1 u16)) | |
0.000003 secs real time | |
0.000003 secs cpu time (0.000003 user, 0.000000 system) | |
no collections | |
64 bytes allocated | |
no minor faults | |
no major faults | |
(time (std/misc/bytes#u8vector->uint u16)) | |
0.000002 secs real time | |
0.000003 secs cpu time (0.000003 user, 0.000000 system) | |
no collections | |
48 bytes allocated | |
no minor faults | |
no major faults | |
(time (u8vector->uint32-0 u32)) | |
0.000004 secs real time | |
0.000004 secs cpu time (0.000004 user, 0.000000 system) | |
no collections | |
304 bytes allocated | |
no minor faults | |
no major faults | |
(time (std/misc/bytes#u8vector->uint u32)) | |
0.000004 secs real time | |
0.000004 secs cpu time (0.000004 user, 0.000000 system) | |
no collections | |
48 bytes allocated | |
no minor faults | |
no major faults | |
(time (u8vector->uint32-1 u32)) | |
0.000004 secs real time | |
0.000004 secs cpu time (0.000004 user, 0.000000 system) | |
no collections | |
304 bytes allocated | |
no minor faults | |
no major faults | |
(time (std/misc/bytes#u8vector->uint u32)) | |
0.000003 secs real time | |
0.000003 secs cpu time (0.000003 user, 0.000000 system) | |
no collections | |
48 bytes allocated | |
no minor faults | |
no major faults | |
(time (u8vector->uint32-2 u32)) | |
0.000003 secs real time | |
0.000003 secs cpu time (0.000003 user, 0.000000 system) | |
no collections | |
160 bytes allocated | |
no minor faults | |
no major faults | |
(time (std/misc/bytes#u8vector->uint u32)) | |
0.000003 secs real time | |
0.000003 secs cpu time (0.000003 user, 0.000000 system) | |
no collections | |
48 bytes allocated | |
no minor faults | |
no major faults | |
(time (u8vector->uint32-3 u32)) | |
0.000003 secs real time | |
0.000003 secs cpu time (0.000003 user, 0.000000 system) | |
no collections | |
160 bytes allocated | |
no minor faults | |
no major faults | |
(time (std/misc/bytes#u8vector->uint u32)) | |
0.000003 secs real time | |
0.000002 secs cpu time (0.000002 user, 0.000000 system) | |
no collections | |
48 bytes allocated | |
no minor faults | |
no major faults | |
(time (u8vector->uint32-4 u32)) | |
0.000003 secs real time | |
0.000003 secs cpu time (0.000003 user, 0.000000 system) | |
no collections | |
160 bytes allocated | |
no minor faults | |
no major faults | |
(time (std/misc/bytes#u8vector->uint u32)) | |
0.000004 secs real time | |
0.000003 secs cpu time (0.000000 user, 0.000003 system) | |
no collections | |
48 bytes allocated | |
no minor faults | |
no major faults |
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
;; comment for gambit | |
(import :std/misc/bytes) | |
;; uncomment for gambit | |
;; (define (u8vector->uint bv) | |
;; (let ((l (fx- (u8vector-length bv) 1))) | |
;; (let loop ((s 0) (i 0)) | |
;; (if (< i l) | |
;; (loop (+ s (* (u8vector-ref bv i) (expt 256 (- l i)))) (+ i 1)) | |
;; (+ s (* (u8vector-ref bv i) (expt 256 (- l i)))))))) | |
(define u16 (make-u8vector 2 #xFF)) | |
(define u32 (make-u8vector 4 #xFF)) | |
(define u64 (make-u8vector 8 #xFF)) | |
(define (u8vector->uint16-0 bv) | |
(+ (* 256 (u8vector-ref bv 0)) (u8vector-ref bv 1))) | |
(time (u8vector->uint16-0 u16)) | |
(time (u8vector->uint u16)) | |
(define (u8vector->uint16-1 bv) | |
(fx+ (fx* 256 (u8vector-ref bv 0)) (u8vector-ref bv 1))) | |
(time (u8vector->uint16-1 u16)) | |
(time (u8vector->uint u16)) | |
(define (u8vector->uint32-0 bv) | |
(+ | |
(* 256 256 256 (u8vector-ref bv 0)) | |
(* 256 256 (u8vector-ref bv 1)) | |
(* 256 (u8vector-ref bv 2)) | |
(u8vector-ref bv 3))) | |
(time (u8vector->uint32-0 u32)) | |
(time (u8vector->uint u32)) | |
(define (u8vector->uint32-1 bv) | |
(fx+ | |
(fx* 256 256 256 (u8vector-ref bv 0)) | |
(fx* 256 256 (u8vector-ref bv 1)) | |
(fx* 256 (u8vector-ref bv 2)) | |
(u8vector-ref bv 3))) | |
(time (u8vector->uint32-1 u32)) | |
(time (u8vector->uint u32)) | |
(define (u8vector->uint32-2 bv) | |
(fx+ | |
(fx* 16777216 (u8vector-ref bv 0)) | |
(fx* 65536 (u8vector-ref bv 1)) | |
(fx* 256 (u8vector-ref bv 2)) | |
(u8vector-ref bv 3))) | |
(time (u8vector->uint32-2 u32)) | |
(time (u8vector->uint u32)) | |
(define (u8vector->uint32-3 bv) | |
(fx+ | |
(fx* (expt 256 3) (u8vector-ref bv 0)) | |
(fx* (expt 256 2) (u8vector-ref bv 1)) | |
(fx* 256 (u8vector-ref bv 2)) | |
(u8vector-ref bv 3))) | |
(time (u8vector->uint32-3 u32)) | |
(time (u8vector->uint u32)) | |
(define (u8vector->uint32-4 bv) | |
(+ | |
(* (expt 256 3) (u8vector-ref bv 0)) | |
(* (expt 256 2) (u8vector-ref bv 1)) | |
(* 256 (u8vector-ref bv 2)) | |
(u8vector-ref bv 3))) | |
(time (u8vector->uint32-4 u32)) | |
(time (u8vector->uint u32)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment