CDBIとDBICのベンチマーク2

deleteメソッドで比較してみる。

Class::DBIの方はdeleteメソッドをクラスメソッドとしても一応呼べるので
CDBI::delete vs DBIC::deleteで
nekokak1とnekokak2ともに1000レコード用意しました。


#! /usr/bin/perl
use strict;
use warnings;
use Benchmark;
use CDBI;
use DBIC;
Benchmark::timethese(1, {
'CDBI' => \&cdbi,
'DBIC' => \&dbic,
});
sub cdbi {
CDBI->delete(name => 'nekokak1');
}
sub dbic {
DBIC->delete(name => 'nekokak2');
}

結果、


Benchmark: timing 1 iterations of CDBI, DBIC...
Delete as class method is deprecated. Use search and delete_all instead. at ./benchmark2.pl line 16
CDBI: 15 wallclock secs ( 4.41 usr + 3.01 sys = 7.42 CPU) @ 0.13/s (n=1)
(warning: too few iterations for a reliable count)
DBIC: 0 wallclock secs ( 0.03 usr + 0.01 sys = 0.04 CPU) @ 25.00/s (n=1)
(warning: too few iterations for a reliable count)

きてますねぇ。歴然ですね。
Use search and delete_all instead.とか言われたので、こうしてみる。


sub cdbi {
CDBI->search(name => 'nekokak1')->delete_all;
}

これも各1000レコードで実験。
結果、


Benchmark: timing 1 iterations of CDBI, DBIC...
CDBI: 14 wallclock secs ( 4.34 usr + 2.85 sys = 7.19 CPU) @ 0.14/s (n=1)
(warning: too few iterations for a reliable count)
DBIC: 0 wallclock secs ( 0.03 usr + 0.01 sys = 0.04 CPU) @ 25.00/s (n=1)
(warning: too few iterations for a reliable count)

CDBIのdeleteはテラヤバス