X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Fbenchmarks.lisp;fp=tests%2Fbenchmarks.lisp;h=8c3a0ce62403a27c8868dca630e199e09e73e034;hb=c55451302afa47365232b6f6ef533a8b9984e8d4;hp=0000000000000000000000000000000000000000;hpb=bd3966e77e9c4e29d575b12d0e6aa78e5848da69;p=clsql.git diff --git a/tests/benchmarks.lisp b/tests/benchmarks.lisp new file mode 100644 index 0000000..8c3a0ce --- /dev/null +++ b/tests/benchmarks.lisp @@ -0,0 +1,74 @@ +;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ====================================================================== +;;;; File: benchmarks.lisp +;;;; Authors: Kevin Rosenberg +;;;; Created: 03/05/2004 +;;;; Updated: $Id: test-init.lisp 9212 2004-05-03 18:44:03Z kevin $ +;;;; +;;;; Benchmark suite +;;;; +;;;; This file is part of CLSQL. +;;;; +;;;; CLSQL users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. +;;;; ====================================================================== + +(in-package #:clsql-tests) + +(defun run-benchmarks-append-report-file (report-file) + (run-function-append-report-file 'run-benchmarks report-file)) + +(clsql:def-view-class bench () + ((a :initarg :a + :type integer) + (b :initarg :b + :type (string 100)) + (c :initarg :c + :type float))) + +(defun run-benchmarks (&key (report-stream *standard-output*) (sexp-report-stream nil) (count 1000)) + (let ((specs (read-specs)) + (*report-stream* report-stream) + (*sexp-report-stream* sexp-report-stream)) + (unless specs + (warn "Not running benchmarks because test configuration file is missing") + (return-from run-benchmarks :skipped)) + (load-necessary-systems specs) + (dolist (db-type +all-db-types+) + (dolist (spec (db-type-spec db-type specs)) + (do-benchmarks-for-backend db-type spec count)))) + (values)) + +(defun do-benchmarks-for-backend (db-type spec count) + (test-connect-to-database db-type spec) + (write-report-banner "Benchmarks" db-type *report-stream*) + + (create-view-from-class 'bench) + (benchmark-init) + (benchmark-selects count) + (drop-view-from-class 'bench)) + +(defun benchmark-init () + (dotimes (i 100) + (execute-command "INSERT INTO BENCH (A,B,C) VALUES (123,'A Medium size string',3.14159)"))) + +(defun benchmark-selects (n) + (let ((*trace-output* *report-stream*)) + (format *report-stream* "~&~%*** QUERY ***~%") + (time + (dotimes (i n) + (query "SELECT * FROM BENCH"))) + (format *report-stream* "~&~%*** QUERY WITH RESULT-TYPES NIL ***~%") + (time + (dotimes (i n) + (query "SELECT * FROM BENCH" :result-types nil))) + (format *report-stream* "~&~%*** QUERY WITH FIELD-NAMES NIL ***~%") + (time + (dotimes (i n) + (query "SELECT * FROM BENCH" :field-names nil))) + )) + + + +