1
0
Fork 0

Benchmarking: Measure execution time

This commit is contained in:
Scott Giese 2018-07-16 12:31:46 -05:00
parent e9dc4b9d8c
commit 0c57e06377
8 changed files with 97 additions and 39 deletions

View file

@ -13,6 +13,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#include <chrono>
#include <memory>
#include <string>
#include <iostream>
@ -126,6 +127,8 @@ double slope_eps = 0.00001;
int main(int argc, char **argv)
{
auto start_time = std::chrono::high_resolution_clock::now();
SGGeod min = SGGeod::fromDeg( -180, -90 );
SGGeod max = SGGeod::fromDeg( 180, 90 );
long position = 0;
@ -277,7 +280,7 @@ int main(int argc, char **argv)
else
{
usage( argc, argv );
exit(-1);
return EXIT_FAILURE;
}
}
@ -318,20 +321,20 @@ int main(int argc, char **argv)
{
TG_LOG( SG_GENERAL, SG_ALERT, "Error: no work directory specified." );
usage( argc, argv );
exit(-1);
return EXIT_FAILURE;
}
if ( input_file == "" )
{
TG_LOG( SG_GENERAL, SG_ALERT, "Error: no input file." );
exit(-1);
return EXIT_FAILURE;
}
sg_gzifstream in( input_file );
if ( !in.is_open() )
{
TG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << input_file );
exit(-1);
return EXIT_FAILURE;
}
// try to figure out which apt.dat version we are reading and bail if version is unsupported
@ -342,7 +345,7 @@ int main(int argc, char **argv)
int code = atoi(line);
if (code == 810 || code > 1100) {
TG_LOG(SG_GENERAL, SG_ALERT, "ERROR: This genapts version does not support apt.data version " << code << " files.");
exit(-1);
return EXIT_FAILURE;
}
// Create the scheduler
@ -390,5 +393,9 @@ int main(int argc, char **argv)
TG_LOG(SG_GENERAL, SG_INFO, "Genapts finished successfully");
return 0;
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
return EXIT_SUCCESS;
}

View file

@ -29,6 +29,9 @@
# define tgSleep(x) sleep(x)
#endif
#include <chrono>
#include <iostream>
#include <boost/thread.hpp>
#include <simgear/debug/logstream.hxx>
@ -96,6 +99,8 @@ int main(int argc, char **argv) {
vector<string> debug_shape_defs;
vector<string> debug_area_defs;
auto start_time = std::chrono::high_resolution_clock::now();
sglog().setLogLevels( SG_ALL, SG_INFO );
//
@ -181,7 +186,7 @@ int main(int argc, char **argv) {
TGAreaDefinitions areas;
if ( areas.init( priorities_file ) ) {
exit( -1 );
return EXIT_FAILURE;
}
// tile work queue
@ -336,5 +341,10 @@ int main(int argc, char **argv) {
constructs.clear();
SG_LOG(SG_GENERAL, SG_ALERT, "[Finished successfully]");
return 0;
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
return EXIT_SUCCESS;
}

View file

@ -27,6 +27,7 @@
#include <simgear/compiler.h>
#include <chrono>
#include <iostream>
#include <string>
@ -47,11 +48,12 @@ int main(int argc, char **argv) {
sglog().setLogLevels( SG_ALL, SG_WARN );
if ( argc != 3 ) {
SG_LOG( SG_GENERAL, SG_ALERT,
"Usage " << argv[0] << " <dem_file> <work_dir>" );
exit(-1);
SG_LOG( SG_GENERAL, SG_ALERT, "Usage " << argv[0] << " <dem_file> <work_dir>" );
return EXIT_FAILURE;
}
auto start_time = std::chrono::high_resolution_clock::now();
string dem_name = argv[1];
string work_dir = argv[2];
@ -72,29 +74,31 @@ int main(int argc, char **argv) {
SGBucket b_max( max );
if ( b_min == b_max ) {
dem.write_area( work_dir, b_min );
dem.write_area( work_dir, b_min );
} else {
SGBucket b_cur;
int dx, dy, i, j;
SGBucket b_cur;
int dx, dy, i, j;
sgBucketDiff(b_min, b_max, &dx, &dy);
cout << "DEM file spans tile boundaries" << endl;
cout << " dx = " << dx << " dy = " << dy << endl;
sgBucketDiff(b_min, b_max, &dx, &dy);
cout << "DEM file spans tile boundaries" << endl;
cout << " dx = " << dx << " dy = " << dy << endl;
if ( (dx > 20) || (dy > 20) ) {
cout << "somethings really wrong!!!!" << endl;
exit(-1);
}
if ( (dx > 20) || (dy > 20) ) {
cout << "somethings really wrong!!!!" << endl;
return EXIT_FAILURE;
}
for ( j = 0; j <= dy; j++ ) {
for ( i = 0; i <= dx; i++ ) {
b_cur = b_min.sibling(i, j);
dem.write_area( work_dir, b_cur );
}
}
for ( j = 0; j <= dy; j++ ) {
for ( i = 0; i <= dx; i++ ) {
b_cur = b_min.sibling(i, j);
dem.write_area( work_dir, b_cur );
}
}
}
return 0;
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
return EXIT_SUCCESS;
}

View file

@ -26,6 +26,7 @@
#include <simgear/compiler.h>
#include <chrono>
#include <cstdlib>
#include <string>
#include <iostream>
@ -55,6 +56,8 @@ int main(int argc, char **argv) {
return EXIT_FAILURE;
}
auto start_time = std::chrono::high_resolution_clock::now();
int resolution = std::stoi(string(argv[1]));
string hgt_name = string(argv[2]);
string work_dir = string(argv[3]);
@ -104,5 +107,9 @@ int main(int argc, char **argv) {
}
}
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
return EXIT_SUCCESS;
}

View file

@ -27,6 +27,7 @@
#include <simgear/compiler.h>
#include <chrono>
#include <string>
#include <iostream>
#include <iomanip>
@ -331,12 +332,13 @@ int main(int argc, char **argv) {
sglog().setLogLevels( SG_ALL, SG_WARN );
if ( argc != 3 ) {
cout << "Usage " << argv[0] << " <hgt_file> <work_dir>"
<< endl;
cout << "Usage " << argv[0] << " <hgt_file> <work_dir>" << endl;
cout << endl;
exit(-1);
return EXIT_FAILURE;
}
auto start_time = std::chrono::high_resolution_clock::now();
string hgt_name = argv[1];
string work_dir = argv[2];
@ -368,7 +370,7 @@ int main(int argc, char **argv) {
if ( (dx > 50) || (dy > 50) ) {
cout << "somethings really wrong!!!!" << endl;
exit(-1);
return EXIT_FAILURE;
}
for ( j = 0; j <= dy; j++ ) {
@ -379,5 +381,9 @@ int main(int argc, char **argv) {
}
}
return 0;
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
return EXIT_SUCCESS;
}

View file

@ -23,6 +23,8 @@
//
#include <algorithm>
#include <chrono>
#include <iostream>
#include <simgear/compiler.h>
#include <simgear/bucket/newbucket.hxx>
@ -426,9 +428,11 @@ int main(int argc, const char **argv)
if ( argc < 3 ) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Usage " << argv[0] << " <work_dir> <datasetname...> [-- <bucket-idx> ...]");
exit(-1);
return EXIT_FAILURE;
}
auto start_time = std::chrono::high_resolution_clock::now();
SGPath work_dir(argv[1]);
work_dir.create_dir( 0755 );
@ -471,7 +475,7 @@ int main(int argc, const char **argv)
SG_LOG(SG_GENERAL, SG_ALERT,
"Could not open dataset '" << datasetnames[i] << "'"
":" << CPLGetLastErrorMsg());
exit(1);
return EXIT_FAILURE;
}
images[i] = new ImageInfo(dataset);
@ -528,5 +532,9 @@ int main(int argc, const char **argv)
}
}
return 0;
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
return EXIT_SUCCESS;
}

View file

@ -22,6 +22,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include <chrono>
#include <string>
#include <map>
@ -536,6 +537,8 @@ int main( int argc, char **argv ) {
char* progname=argv[0];
string datasource,work_dir;
auto start_time = std::chrono::high_resolution_clock::now();
sglog().setLogLevels( SG_ALL, SG_INFO );
while (argc>1) {
@ -718,5 +721,9 @@ int main( int argc, char **argv ) {
SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets");
results.Save( save_shapefiles );
return 0;
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
return EXIT_SUCCESS;
}

View file

@ -23,6 +23,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <chrono>
#include <string>
#include <stdio.h>
#include <errno.h>
@ -301,6 +302,8 @@ int main(int argc, char** argv) {
sglog().setLogLevels( SG_ALL, SG_INFO );
int option;
auto start_time = std::chrono::high_resolution_clock::now();
while ((option=getopt_long(argc,argv,"hm:x:e:fvj:",options,NULL))!=-1) {
switch (option) {
case 'h':
@ -362,4 +365,10 @@ int main(int argc, char** argv) {
}
SG_LOG(SG_GENERAL, SG_INFO, "Work queue is empty\n");
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
return EXIT_SUCCESS;
}