Use SGTimestamp for statistics gathering.
Use time(0) and standard C++ <ctime> for date / time
This commit is contained in:
parent
7777fc4bc2
commit
cf5bb76ee8
3 changed files with 58 additions and 101 deletions
|
@ -6,6 +6,7 @@
|
|||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
@ -468,15 +469,13 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
// parse main airport information
|
||||
double apt_lon = 0.0, apt_lat = 0.0;
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
struct timeval build_start;
|
||||
struct timeval build_end;
|
||||
struct timeval cleanup_start;
|
||||
struct timeval cleanup_end;
|
||||
struct timeval triangulation_start;
|
||||
struct timeval triangulation_end;
|
||||
struct timeval log_time;
|
||||
#endif
|
||||
SGTimeStamp build_start;
|
||||
SGTimeStamp build_end;
|
||||
SGTimeStamp cleanup_start;
|
||||
SGTimeStamp cleanup_end;
|
||||
SGTimeStamp triangulation_start;
|
||||
SGTimeStamp triangulation_end;
|
||||
time_t log_time;
|
||||
|
||||
// Find the average of all the runway and heliport long / lats
|
||||
int num_samples = 0;
|
||||
|
@ -511,9 +510,7 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
}
|
||||
|
||||
// Starting to clip the polys (for now - only UNIX builds)
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&build_start, NULL);
|
||||
#endif
|
||||
build_start.stamp();
|
||||
|
||||
// Add the linear features
|
||||
if (features.size())
|
||||
|
@ -538,10 +535,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
SG_LOG(SG_GENERAL, SG_DEBUG, "no markings");
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&log_time, NULL);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished building Linear Features for " << icao << " at " << ctime(&log_time.tv_sec) );
|
||||
#endif
|
||||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished building Linear Features for " << icao << " at " << ctime(&log_time) );
|
||||
|
||||
// Build runways next
|
||||
for ( unsigned int i=0; i<runways.size(); i++ )
|
||||
|
@ -565,10 +560,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
merge_slivers( rwy_polys, slivers );
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&log_time, NULL);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished building runways for " << icao << " at " << ctime(&log_time.tv_sec) );
|
||||
#endif
|
||||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished building runways for " << icao << " at " << ctime(&log_time) );
|
||||
|
||||
if (lightobjects.size())
|
||||
{
|
||||
|
@ -636,10 +629,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
SG_LOG(SG_GENERAL, SG_DEBUG, "no pavements");
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&log_time, NULL);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished building pavements for " << icao << " at " << ctime(&log_time.tv_sec) );
|
||||
#endif
|
||||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished building Pavements for " << icao << " at " << ctime(&log_time) );
|
||||
|
||||
// Build runway shoulders here
|
||||
#if 0
|
||||
|
@ -677,15 +668,10 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
TGPolygon divided_base = tgPolygonSplitLongEdges( filled_base, 200.0 );
|
||||
TGPolygon base_poly = tgPolygonDiffClipper( divided_base, accum );
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&build_end, NULL);
|
||||
timersub(&build_end, &build_start, &build_time);
|
||||
#endif
|
||||
build_end.stamp();
|
||||
build_time = build_end - build_start;
|
||||
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&cleanup_start, NULL);
|
||||
#endif
|
||||
cleanup_start.stamp();
|
||||
|
||||
// add segments to polygons to remove any possible "T"
|
||||
// intersections
|
||||
|
@ -752,10 +738,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&log_time, NULL);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished collecting nodes for " << icao << " at " << ctime(&log_time.tv_sec) );
|
||||
#endif
|
||||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished collecting nodes for " << icao << " at " << ctime(&log_time) );
|
||||
|
||||
// second pass : runways
|
||||
for ( unsigned int k = 0; k < rwy_polys.size(); ++k )
|
||||
|
@ -784,10 +768,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
line_polys[k].set_poly( poly );
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&log_time, NULL);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished adding intermediate nodes for " << icao << " at " << ctime(&log_time.tv_sec) );
|
||||
#endif
|
||||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished adding intermediate nodes for " << icao << " at " << ctime(&log_time) );
|
||||
|
||||
for ( unsigned int k = 0; k < line_polys.size(); ++k )
|
||||
{
|
||||
|
@ -806,10 +788,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
line_polys[k].set_poly( poly );
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&log_time, NULL);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished cleaning polys for " << icao << " at " << ctime(&log_time.tv_sec) );
|
||||
#endif
|
||||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished cleaning polys for " << icao << " at " << ctime(&log_time) );
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "add nodes base ");
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, " before: " << base_poly);
|
||||
|
@ -843,14 +823,10 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
pvmt_polys[k].set_poly( poly );
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&cleanup_end, NULL);
|
||||
timersub(&cleanup_end, &cleanup_start, &cleanup_time);
|
||||
#endif
|
||||
cleanup_end.stamp();
|
||||
cleanup_time = cleanup_end - cleanup_start;
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&triangulation_start, NULL);
|
||||
#endif
|
||||
triangulation_start.stamp();
|
||||
|
||||
// tesselate the polygons and prepair them for final output
|
||||
for ( unsigned int i = 0; i < rwy_polys.size(); ++i )
|
||||
|
@ -954,10 +930,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Tesselating base poly - done : contours = " << base_tris.contours());
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&triangulation_end, NULL);
|
||||
timersub(&triangulation_end, &triangulation_start, &triangulation_time);
|
||||
#endif
|
||||
triangulation_end.stamp();
|
||||
triangulation_time = triangulation_end - triangulation_start;
|
||||
|
||||
//
|
||||
// We should now have the runway polygons all generated with their
|
||||
|
|
|
@ -4,13 +4,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h> // for timing
|
||||
#endif
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
||||
#include "runway.hxx"
|
||||
#include "object.hxx"
|
||||
|
@ -95,17 +89,17 @@ public:
|
|||
return icao;
|
||||
}
|
||||
|
||||
void GetBuildTime( struct timeval& tm )
|
||||
void GetBuildTime( SGTimeStamp& tm )
|
||||
{
|
||||
tm = build_time;
|
||||
}
|
||||
|
||||
void GetTriangulationTime( struct timeval& tm )
|
||||
void GetTriangulationTime( SGTimeStamp& tm )
|
||||
{
|
||||
tm = triangulation_time;
|
||||
}
|
||||
|
||||
void GetCleanupTime( struct timeval& tm )
|
||||
void GetCleanupTime( SGTimeStamp& tm )
|
||||
{
|
||||
tm = cleanup_time;
|
||||
}
|
||||
|
@ -133,9 +127,9 @@ private:
|
|||
ClosedPoly* boundary;
|
||||
|
||||
// stats
|
||||
struct timeval build_time;
|
||||
struct timeval cleanup_time;
|
||||
struct timeval triangulation_time;
|
||||
SGTimeStamp build_time;
|
||||
SGTimeStamp cleanup_time;
|
||||
SGTimeStamp triangulation_time;
|
||||
|
||||
// debug
|
||||
int dbg_rwy_poly;
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h> // for timing
|
||||
#endif
|
||||
#include <ctime>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
||||
#include "parser.hxx"
|
||||
|
||||
|
@ -334,15 +329,14 @@ void Parser::SetDebugPolys( int rwy, int pvmt, int feat, int base )
|
|||
void Parser::Parse( string last_apt_file )
|
||||
{
|
||||
char tmp[2048];
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
struct timeval parse_start;
|
||||
struct timeval parse_end;
|
||||
struct timeval parse_time;
|
||||
struct timeval build_time;
|
||||
struct timeval clean_time;
|
||||
struct timeval triangulation_time;
|
||||
#endif
|
||||
|
||||
SGTimeStamp parse_start;
|
||||
SGTimeStamp parse_end;
|
||||
SGTimeStamp parse_time;
|
||||
SGTimeStamp build_time;
|
||||
SGTimeStamp clean_time;
|
||||
SGTimeStamp triangulation_time;
|
||||
time_t log_time;
|
||||
|
||||
ifstream in( filename.c_str() );
|
||||
if ( !in.is_open() )
|
||||
|
@ -357,11 +351,10 @@ void Parser::Parse( string last_apt_file )
|
|||
SetState(STATE_NONE);
|
||||
in.clear();
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&parse_start, NULL);
|
||||
parse_start.stamp();
|
||||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "\n*******************************************************************" );
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Parsing airport " << airport_icaos[i] << " at " << parse_positions[i] << " start time " << ctime(&parse_start.tv_sec) );
|
||||
#endif
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Start airport " << airport_icaos[i] << " at " << parse_positions[i] << ": start time " << ctime(&log_time) );
|
||||
|
||||
in.seekg(parse_positions[i], ios::beg);
|
||||
|
||||
|
@ -378,33 +371,29 @@ void Parser::Parse( string last_apt_file )
|
|||
ParseLine(tmp);
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
gettimeofday(&parse_end, NULL);
|
||||
timersub(&parse_end, &parse_start, &parse_time);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished parsing airport " << airport_icaos[i] << " at " << ctime(&parse_end.tv_sec) );
|
||||
#endif
|
||||
parse_end.stamp();
|
||||
parse_time = parse_end - parse_start;
|
||||
|
||||
// write the airport BTG
|
||||
if (cur_airport)
|
||||
{
|
||||
cur_airport->BuildBtg( work_dir, elevation );
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
cur_airport->GetBuildTime( build_time );
|
||||
cur_airport->GetCleanupTime( clean_time );
|
||||
cur_airport->GetTriangulationTime( triangulation_time );
|
||||
#endif
|
||||
|
||||
delete cur_airport;
|
||||
cur_airport = NULL;
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Time to parse " << parse_time.tv_sec << ":" << parse_time.tv_usec );
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Time to build " << build_time.tv_sec << ":" << build_time.tv_usec );
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Time to clean up " << clean_time.tv_sec << ":" << clean_time.tv_usec );
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Time to triangulate " << triangulation_time.tv_sec << ":" << triangulation_time.tv_usec );
|
||||
#endif
|
||||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished airport " << airport_icaos[i] << ": end time " << ctime(&log_time) );
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Time to parse " << parse_time );
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Time to build " << build_time );
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Time to clean up " << clean_time );
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Time to triangulate " << triangulation_time );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue