#!/usr/bin/perl use strict; use warnings; use DBI; use Benchmark; my $host = 'server.lan.de'; my $database = 'benchmark_test'; my $user = 'benchmarker'; my $passwd = 'tester'; timethese(5, { 'Test mit Platzhaltern' => \&test_without, 'Test ohne Platzhalter' => \&test_with } ); sub test_without { my $dbh = DBI->connect("DBI:mysql:database=$database;host=$host;",$user,$passwd,{PrintError => 1, RaiseError => 1}) or die DBI::errstr; my $sql = qq| SELECT * FROM testobject WHERE col2 = 'lasdjfhoyxcv,asiwezrfbc,yprepare( $sql ) or die DBI::errstr; for (0 .. 30) { $sth->execute() or die DBI::errstr; #print "Without: $_ \n"; } $sth->finish(); $dbh->disconnect(); } sub test_with { my $dbh = DBI->connect("DBI:mysql:database=$database;host=$host;",$user,$passwd,{PrintError => 1, RaiseError => 1}) or die DBI::errstr; my $sql = qq| SELECT * FROM testobject WHERE col2 = ? |; my $sth = $dbh->prepare( $sql ) or die DBI::errstr; for (0 .. 30) { $sth->execute('lasdjfhoyxcv,asiwezrfbc,yfinish(); $dbh->disconnect() }