Hey Steve,<div><br></div><div>Thanks for your comprehensive review of the methods. It is very useful.</div><div><br></div><div>Since I really care about the core performance of each algorithm, I would do this "<span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">you could add timing collection in your C/C++ code</span><span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"> </span>".</div>
<div><br></div><div>Thanks,</div><div>Jinfu</div><div><br><div class="gmail_quote">On Sat, Jun 30, 2012 at 11:27 AM, Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 6/29/2012 10:38 PM, Jinfu Leng wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hey all,<br>
<br>
I almost finished my code for the new algorithm. Next I want to test the<br>
performance (regarding computing time) of these algorithms. I am<br>
planning to randomly generate some source-target pairs, and use them for<br>
testing. But I do not know where to start.<br>
<br>
My questions are:<br>
How to execute the query from the code? (I always test the algorithms<br>
from pgadmin)<br>
How to save the results? (I want to save the total distance at least,<br>
and then I can use these results to make sure all the algorithms are right)<br>
How to measure the computing time of each algorithm?<br>
</blockquote>
<br></div></div>
There are a lot of ways to build automated tests. I will outline some of them below. One big thing to watch out for is to be aware of WHAT you are measuring.<br>
<br>
1. you can use linux command line in a script like:<br>
<br>
time psql -U user -h localhost databse -f input.sql<br>
<br>
in the input.sql you can start off with '\timing on' to get it to echo query times for each command. There are other command line options read 'man psql' for details that might be useful.<br>
<br>
Be aware that you are measuring psql startup time, database connect time, and the query time of the commands, the transfer of the results and printing the results. If the query time is small relative to all the other stuff. this might be problematic.<br>
<br>
2. you can use a perl script with DBI and Time::HighRes modules to measure the time a query takes to run. If you are knowledgeable in perl this also makes it easy to read data and query input from files and log the results to a file.<br>
<br>
3. If you like plpgsql or SQL, you could create a table in your database with the data, queries, and tests that you want to run. maybe with a structure like:<br>
<br>
create table testdata (<br>
testid integer not null primary key,<br>
query text,<br>
expected_results text,<br>
...<br>
);<br>
<br>
And a table for results:<br>
<br>
create table testresults {<br>
id integer not null primary key,<br>
testid integer,<br>
run_date time stamp with timezone,<br>
duration integer,<br>
pass integer,<br>
comments text<br>
);<br>
<br>
Then you could write a stored procedure(s) like:<br>
select * from runtests();<br>
select * from runtests(testid);<br>
<br>
this would read the test(s) from testdata<br>
run each test requested<br>
store the results in testresults<br>
and return the results one for each test run.<br>
<br>
You can do timing via SQL and plpgsql using timestamps and extracting microseconds from the interval between the start and end timestamps that can bracket a query.<br>
<br>
4. you could add timing collection in your C/C++ code and return it via the NOTICE facility, like what we do for debugging.<br>
<br>
And I'm sure there are other ways to do this.<br>
<br>
-Steve<br>
______________________________<u></u>_________________<br>
pgrouting-dev mailing list<br>
<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-dev</a><br>
</blockquote></div><br></div>