1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
guile/benchmark-suite/benchmarks/bytevectors.bm
Neil Jerram 53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00

100 lines
3 KiB
Scheme
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; -*- mode: scheme; coding: latin-1; -*-
;;; R6RS Byte Vectors.
;;;
;;; Copyright 2009 Ludovic Courtès <ludo@gnu.org>
;;;
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public License
;;; as published by the Free Software Foundation; either version 3, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU Lesser General Public License for more details.
;;;
;;; You should have received a copy of the GNU Lesser General Public
;;; License along with this software; see the file COPYING.LESSER. If
;;; not, write to the Free Software Foundation, Inc., 51 Franklin
;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (benchmarks bytevector)
:use-module (rnrs bytevector)
:use-module (srfi srfi-4)
:use-module (benchmark-suite lib))
(define bv (make-bytevector 16384))
(define %native-endianness
(native-endianness))
(define %foreign-endianness
(if (eq? (native-endianness) (endianness little))
(endianness big)
(endianness little)))
(define u8v (make-u8vector 16384))
(define u16v (make-u16vector 8192))
(define u32v (make-u32vector 4196))
(define u64v (make-u64vector 2048))
(with-benchmark-prefix "ref/set!"
(benchmark "bytevector-u8-ref" 1000000
(bytevector-u8-ref bv 0))
(benchmark "bytevector-u16-ref (foreign)" 1000000
(bytevector-u16-ref bv 0 %foreign-endianness))
(benchmark "bytevector-u16-ref (native)" 1000000
(bytevector-u16-ref bv 0 %native-endianness))
(benchmark "bytevector-u16-native-ref" 1000000
(bytevector-u16-native-ref bv 0))
(benchmark "bytevector-u32-ref (foreign)" 1000000
(bytevector-u32-ref bv 0 %foreign-endianness))
(benchmark "bytevector-u32-ref (native)" 1000000
(bytevector-u32-ref bv 0 %native-endianness))
(benchmark "bytevector-u32-native-ref" 1000000
(bytevector-u32-native-ref bv 0))
(benchmark "bytevector-u64-ref (foreign)" 1000000
(bytevector-u64-ref bv 0 %foreign-endianness))
(benchmark "bytevector-u64-ref (native)" 1000000
(bytevector-u64-ref bv 0 %native-endianness))
(benchmark "bytevector-u64-native-ref" 1000000
(bytevector-u16-native-ref bv 0)))
(with-benchmark-prefix "lists"
(benchmark "bytevector->u8-list" 2000
(bytevector->u8-list bv))
(benchmark "bytevector->uint-list 16-bit" 2000
(bytevector->uint-list bv (native-endianness) 2))
(benchmark "bytevector->uint-list 64-bit" 2000
(bytevector->uint-list bv (native-endianness) 8)))
(with-benchmark-prefix "SRFI-4" ;; for comparison
(benchmark "u8vector-ref" 1000000
(u8vector-ref u8v 0))
(benchmark "u16vector-ref" 1000000
(u16vector-ref u16v 0))
(benchmark "u32vector-ref" 1000000
(u32vector-ref u32v 0))
(benchmark "u64vector-ref" 1000000
(u64vector-ref u64v 0)))