srfi-1.bm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ;;; -*- mode: scheme; coding: utf-8; -*-
  2. ;;; SRFI-1.
  3. ;;;
  4. ;;; Copyright 2010, 2011 Free Software Foundation, Inc.
  5. ;;;
  6. ;;; This program is free software; you can redistribute it and/or
  7. ;;; modify it under the terms of the GNU Lesser General Public License
  8. ;;; as published by the Free Software Foundation; either version 3, or
  9. ;;; (at your option) any later version.
  10. ;;;
  11. ;;; This program is distributed in the hope that it will be useful,
  12. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU Lesser General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU Lesser General Public
  17. ;;; License along with this software; see the file COPYING.LESSER. If
  18. ;;; not, write to the Free Software Foundation, Inc., 51 Franklin
  19. ;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. (define-module (benchmarks srfi-1)
  21. #:use-module (srfi srfi-1)
  22. #:use-module (benchmark-suite lib))
  23. (define %big-list
  24. (iota 1000000))
  25. (define %small-list
  26. (iota 10))
  27. (with-benchmark-prefix "fold"
  28. (benchmark "big" 30
  29. (fold (lambda (x y) y) #f %big-list))
  30. (benchmark "small" 2000000
  31. (fold (lambda (x y) y) #f %small-list)))
  32. (with-benchmark-prefix "drop-while"
  33. (benchmark "big" 30
  34. (drop-while (lambda (n) #t) %big-list))
  35. (benchmark "small" 2000000
  36. (drop-while (lambda (n) #t) %small-list)))
  37. (with-benchmark-prefix "map"
  38. (benchmark "big" 30
  39. (map (lambda (x) x) %big-list))
  40. (benchmark "small" 2000000
  41. (map (lambda (x) x) %small-list)))
  42. (with-benchmark-prefix "for-each"
  43. (benchmark "big" 30
  44. (for-each (lambda (x) #f) %big-list))
  45. (benchmark "small" 2000000
  46. (for-each (lambda (x) #f) %small-list)))