write.bm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ;;; write.bm --- Exercise the printer. -*- Scheme -*-
  2. ;;;
  3. ;;; Copyright (C) 2010 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 write)
  20. #:use-module (benchmark-suite lib))
  21. (define %len 50000)
  22. (define %string-with-escapes
  23. (list->string (map integer->char (iota %len))))
  24. (define %string-without-escapes
  25. (make-string %len #\a))
  26. ;; Use Unicode-capable ports.
  27. (fluid-set! %default-port-encoding "UTF-8")
  28. (define %null
  29. (%make-void-port OPEN_WRITE))
  30. (with-benchmark-prefix "write"
  31. (benchmark "string with escapes" 50
  32. (write %string-with-escapes %null))
  33. (benchmark "string without escapes" 50
  34. (write %string-without-escapes %null)))
  35. (with-benchmark-prefix "display"
  36. (benchmark "string with escapes" 1000
  37. (display %string-with-escapes %null))
  38. (benchmark "string without escapes" 1000
  39. (display %string-without-escapes %null)))