。。。这对比显然反应 CPython 的语言实现性能非常渣啊,我都说了 cymysql vs pymysql,
raw=True vs raw=False。。。
刚用 Perl 的 DBD::mysql + Text::CSV_XS 试验了下,速度是 Python 版 5 倍,这让一个
想叛离 Perl 投奔 Python 的我情何以堪。。。真心不是踢版来着,我花了好几个小时找
Python 的各种模块各种试验。。。
#!/usr/bin/perl
use Benchmark ':hireswallclock';
use DBI;
use Text::CSV_XS;
use strict;
use warnings;
my $csv = Text::CSV_XS->new({ binary => 1, eol => $/ });
my $dbh = DBI->connect("DBI:mysql:database=db1;host=192.168.99.101;port=32787",
"root", "",
{'RaiseError' => 1});
sub bench {
my $sth = $dbh->prepare("SELECT * FROM order");
$sth->execute();
while (my $ref = $sth->fetchrow_arrayref()) {
$csv->print(\*STDERR, $ref);
}
$sth->finish();
}
timethis(10, \&bench);
$dbh->disconnect();
【 在 hgoldfish (老鱼) 的大作中提到: 】
: 标 题: Re: Python 几个 MySQL client 库性能对比
: 发信站: 水木社区 (Sun Oct 30 21:44:07 2016), 转信
: 这个东西主要是 io 时间,跟语言效率没有太大关系吧。
: 【 在 Dieken (风催草低 - 明月何尝不照人) 的大作中提到: 】
: : 从 cymysql vs pymysql,以及 mysql-connector raw=True vs raw=False 可以看出
: : CPython 的性能渣的触目惊心。
: : ...................
: --
: 灭绝人性啊