bytevector-io.bm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ;;; bytevector-io.bm --- Exercise bytevector I/O primitives. -*- Scheme -*-
  2. ;;;
  3. ;;; Copyright (C) 2008, 2017 Free Software Foundation, Inc.
  4. ;;;
  5. ;;; This program is free software; you can redistribute it and/or
  6. ;;; modify it under the terms of the GNU Lesser General Public License
  7. ;;; as published by the Free Software Foundation; either version 3, or
  8. ;;; (at your option) any later version.
  9. ;;;
  10. ;;; This program is distributed in the hope that it will be useful,
  11. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;;; GNU Lesser General Public License for more details.
  14. ;;;
  15. ;;; You should have received a copy of the GNU Lesser General Public
  16. ;;; License along with this software; see the file COPYING.LESSER. If
  17. ;;; not, write to the Free Software Foundation, Inc., 51 Franklin
  18. ;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. (define-module (benchmarks bytevector-io)
  20. :use-module (benchmark-suite lib)
  21. :use-module (rnrs io ports)
  22. :use-module (rnrs bytevectors))
  23. (define file-name
  24. (tmpnam))
  25. (define %buffer-size
  26. 7777)
  27. (define buf
  28. (make-u8vector %buffer-size))
  29. (with-benchmark-prefix "bytevector i/o"
  30. (benchmark "put-bytevector" 4000
  31. (let ((output (open-output-file file-name)))
  32. (put-bytevector output buf)
  33. (close output)))
  34. (benchmark "get-bytevector-n!" 20000
  35. (let ((input (open-input-file file-name)))
  36. (setvbuf input 'none)
  37. (get-bytevector-n! input buf 0 (bytevector-length buf))
  38. (close input)))
  39. (benchmark "get-bytevector-n" 20000
  40. (let ((input (open-input-file file-name)))
  41. (setvbuf input 'none)
  42. (get-bytevector-n input (bytevector-length buf))
  43. (close input))))