what's wrong with this code
Posted: Sun Sep 28, 2008 3:50 pm
Hi there
I have a problem wit this script.
For some reason it doesn't return any values.
I'm running the script:
root@ubuntu-jfs:~# php script.php
The output of the script is always:
microtime 1222634669.82
number_of_tablies
database: tap
tables:
total records:
Write rows per sec: 0
Reads rows per sec: 0 sec.
I'm not very good in PHP I'm just trying to run a benchmark to establish what is the mysql performance on different types of file systems.
Please help if you can.
Regards
Pete
#!/usr/bin/php
<?
$database_name = 'tap';
$number_of_tables = $argv[1];
$number_of_records = $argv[2];
mysql_connect("localhost","root","madmin");
$x=1;
for ($i=1; $i<=$number_of_tables; $i++) {
echo $i;
$result = mysql_query("CREATE TABLE $database_name.table_$i (id INT NOT NULL, c BLOB not null) engine=innodb") or die("Invalid query: " . mysql_error());
};
$t_temp=microtime(1);
for ($j=1; $j<=$number_of_records; $j++)
{
$i=rand(1,$number_of_tables);
$result1 = mysql_query("INSERT INTO $database_name.table_$i (id,c) VALUES ('$j',repeat('0',4000))") or die("Invalid query: " . mysql_error());
}
$t_write_row=$number_of_records/(microtime(1)-$t_temp);
$t_temp=microtime(1);
for ($i=1; $i<=$number_of_tables; $i++) {
$result1 = mysql_query("SELECT count(*) FROM $database_name.table_$i where c='test'" ) or die("Invalid query: " . mysql_error());
};
$t_read_row=$number_of_records/(microtime(1)-$t_temp);
echo "microtime ".
$t_temp. "\n";
echo "number_of_tablies ".
$argv[1]. "\n";
echo "database: ".
$database_name . "\n";
echo "tables: ".
$number_of_tables.
"\n".
"total records: ".
$number_of_records.
"\n".
"Write rows per sec: ".
$t_write_row.
"\n".
"Reads rows per sec: ".
$t_read_row.
" sec.\n";
#echo mysql_result($result,0);
?>
I have a problem wit this script.
For some reason it doesn't return any values.
I'm running the script:
root@ubuntu-jfs:~# php script.php
The output of the script is always:
microtime 1222634669.82
number_of_tablies
database: tap
tables:
total records:
Write rows per sec: 0
Reads rows per sec: 0 sec.
I'm not very good in PHP I'm just trying to run a benchmark to establish what is the mysql performance on different types of file systems.
Please help if you can.
Regards
Pete
Code: Select all
<?
$database_name = 'tap';
$number_of_tables = $argv[1];
$number_of_records = $argv[2];
mysql_connect("localhost","root","madmin");
$x=1;
for ($i=1; $i<=$number_of_tables; $i++) {
echo $i;
$result = mysql_query("CREATE TABLE $database_name.table_$i (id INT NOT NULL, c BLOB not null) engine=innodb") or die("Invalid query: " . mysql_error());
};
$t_temp=microtime(1);
for ($j=1; $j<=$number_of_records; $j++)
{
$i=rand(1,$number_of_tables);
$result1 = mysql_query("INSERT INTO $database_name.table_$i (id,c) VALUES ('$j',repeat('0',4000))") or die("Invalid query: " . mysql_error());
}
$t_write_row=$number_of_records/(microtime(1)-$t_temp);
$t_temp=microtime(1);
for ($i=1; $i<=$number_of_tables; $i++) {
$result1 = mysql_query("SELECT count(*) FROM $database_name.table_$i where c='test'" ) or die("Invalid query: " . mysql_error());
};
$t_read_row=$number_of_records/(microtime(1)-$t_temp);
echo "microtime ".
$t_temp. "\n";
echo "number_of_tablies ".
$argv[1]. "\n";
echo "database: ".
$database_name . "\n";
echo "tables: ".
$number_of_tables.
"\n".
"total records: ".
$number_of_records.
"\n".
"Write rows per sec: ".
$t_write_row.
"\n".
"Reads rows per sec: ".
$t_read_row.
" sec.\n";
#echo mysql_result($result,0);
?>