diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index a39555f6..2321ee39 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -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 -#endif - -#ifdef HAVE_SYS_TIME_H -# include // for timing -#endif +#include #include #include +#include #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 ); } }