structs.bm 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ;;; -*- mode: scheme; coding: iso-8859-1; -*-
  2. ;;; Structs.
  3. ;;;
  4. ;;; Copyright 2009 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 structs)
  21. :use-module (benchmark-suite lib))
  22. ;; Note: Use `--iteration-factor' to change this.
  23. (define iterations 2000000)
  24. (define vtable2
  25. (make-vtable "prpr"))
  26. (define vtable7
  27. (make-vtable (string-concatenate (make-list 7 "pr"))))
  28. (with-benchmark-prefix "constructors"
  29. (benchmark "make-struct2 (opcode)" iterations
  30. (make-struct vtable2 0 1 2))
  31. (benchmark "make-struct2 (procedure)" iterations
  32. (let ((s make-struct))
  33. (s vtable2 0 1 2)))
  34. (benchmark "make-struct7 (opcode)" iterations
  35. (make-struct vtable7 0 1 2 3 4 5 6 7))
  36. (benchmark "make-struct7 (procedure)" iterations
  37. (let ((s make-struct))
  38. (s vtable7 0 1 2 3 4 5 6 7))))
  39. (with-benchmark-prefix "pairs" ;; for comparison
  40. (benchmark "cons (opcode)" iterations
  41. (cons 1 2))
  42. (benchmark "cons (procedure)" iterations
  43. (let ((c cons))
  44. (c 1 2)))
  45. (benchmark "list (opcode)" iterations
  46. (list 1 2 3 4 5 6 7))
  47. (benchmark "list (procedure)" iterations
  48. (let ((l list))
  49. (l 1 2 3 4 5 6 7)))
  50. (benchmark "make-list" iterations
  51. (make-list 7)))