mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Replace <ctime> library by <chrono>
This commit is contained in:
		| @@ -31,7 +31,7 @@ | ||||
|  */ | ||||
|  | ||||
|  | ||||
| #include <ctime> | ||||
| #include <chrono> | ||||
| #include <iostream> | ||||
| #include <gnuradio/top_block.h> | ||||
| #include <gnuradio/blocks/file_source.h> | ||||
| @@ -149,11 +149,11 @@ void GlonassL1CaDllPllCAidTrackingTest::init() | ||||
|     config->set_property("Tracking_1G.dll_bw_hz", "0.5"); | ||||
| } | ||||
|  | ||||
|  | ||||
| TEST_F(GlonassL1CaDllPllCAidTrackingTest, ValidationOfResults) | ||||
| { | ||||
|     struct timeval tv; | ||||
|     long long int begin = 0; | ||||
|     long long int end = 0; | ||||
|     std::chrono::time_point<std::chrono::system_clock> start, end; | ||||
|     std::chrono::duration<double> elapsed_seconds(0); | ||||
|     int fs_in = 6625000; | ||||
|     int nsamples = fs_in*4e-3*2; | ||||
|  | ||||
| @@ -170,15 +170,15 @@ TEST_F(GlonassL1CaDllPllCAidTrackingTest, ValidationOfResults) | ||||
|  | ||||
|     ASSERT_NO_THROW( { | ||||
|         tracking->set_channel(gnss_synchro.Channel_ID); | ||||
|     }) << "Failure setting channel." << std::endl; | ||||
|     }) << "Failure setting channel."; | ||||
|  | ||||
|     ASSERT_NO_THROW( { | ||||
|         tracking->set_gnss_synchro(&gnss_synchro); | ||||
|     }) << "Failure setting gnss_synchro." << std::endl; | ||||
|     }) << "Failure setting gnss_synchro."; | ||||
|  | ||||
|     ASSERT_NO_THROW( { | ||||
|         tracking->connect(top_block); | ||||
|     }) << "Failure connecting tracking to the top_block." << std::endl; | ||||
|     }) << "Failure connecting tracking to the top_block."; | ||||
|  | ||||
|     ASSERT_NO_THROW( { | ||||
|         gr::analog::sig_source_c::sptr sin_source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000, 1, gr_complex(0)); | ||||
| @@ -192,18 +192,17 @@ TEST_F(GlonassL1CaDllPllCAidTrackingTest, ValidationOfResults) | ||||
|         top_block->connect(valve, 0, tracking->get_left_block(), 0); | ||||
|         top_block->connect(tracking->get_right_block(), 0, sink, 0); | ||||
|         top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); | ||||
|     }) << "Failure connecting the blocks of tracking test." << std::endl; | ||||
|     }) << "Failure connecting the blocks of tracking test."; | ||||
|  | ||||
|     tracking->start_tracking(); | ||||
|  | ||||
|     EXPECT_NO_THROW( { | ||||
|         gettimeofday(&tv, NULL); | ||||
|         begin = tv.tv_sec *1000000 + tv.tv_usec; | ||||
|         start = std::chrono::system_clock::now(); | ||||
|         top_block->run(); // Start threads and wait | ||||
|         gettimeofday(&tv, NULL); | ||||
|         end = tv.tv_sec *1000000 + tv.tv_usec; | ||||
|     }) << "Failure running the top_block." << std::endl; | ||||
|         end = std::chrono::system_clock::now(); | ||||
|         elapsed_seconds = end - start; | ||||
|     }) << "Failure running the top_block."; | ||||
|  | ||||
|     // TODO: Verify tracking results | ||||
|     std::cout <<  "Tracked " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; | ||||
|     std::cout <<  "Tracked " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; | ||||
| } | ||||
|   | ||||
| @@ -31,7 +31,7 @@ | ||||
|  */ | ||||
|  | ||||
|  | ||||
| #include <ctime> | ||||
| #include <chrono> | ||||
| #include <iostream> | ||||
| #include <gnuradio/top_block.h> | ||||
| #include <gnuradio/blocks/file_source.h> | ||||
| @@ -151,9 +151,8 @@ void GlonassL1CaDllPllTrackingTest::init() | ||||
|  | ||||
| TEST_F(GlonassL1CaDllPllTrackingTest, ValidationOfResults) | ||||
| { | ||||
|     struct timeval tv; | ||||
|     long long int begin = 0; | ||||
|     long long int end = 0; | ||||
|     std::chrono::time_point<std::chrono::system_clock> start, end; | ||||
|     std::chrono::duration<double> elapsed_seconds(0); | ||||
|     int fs_in = 6625000; | ||||
|     int nsamples = fs_in*4e-3*2; | ||||
|  | ||||
| @@ -170,15 +169,15 @@ TEST_F(GlonassL1CaDllPllTrackingTest, ValidationOfResults) | ||||
|  | ||||
|     ASSERT_NO_THROW( { | ||||
|         tracking->set_channel(gnss_synchro.Channel_ID); | ||||
|     }) << "Failure setting channel." << std::endl; | ||||
|     }) << "Failure setting channel."; | ||||
|  | ||||
|     ASSERT_NO_THROW( { | ||||
|         tracking->set_gnss_synchro(&gnss_synchro); | ||||
|     }) << "Failure setting gnss_synchro." << std::endl; | ||||
|     }) << "Failure setting gnss_synchro."; | ||||
|  | ||||
|     ASSERT_NO_THROW( { | ||||
|         tracking->connect(top_block); | ||||
|     }) << "Failure connecting tracking to the top_block." << std::endl; | ||||
|     }) << "Failure connecting tracking to the top_block."; | ||||
|  | ||||
|     ASSERT_NO_THROW( { | ||||
|         gr::analog::sig_source_c::sptr sin_source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000, 1, gr_complex(0)); | ||||
| @@ -192,18 +191,17 @@ TEST_F(GlonassL1CaDllPllTrackingTest, ValidationOfResults) | ||||
|         top_block->connect(valve, 0, tracking->get_left_block(), 0); | ||||
|         top_block->connect(tracking->get_right_block(), 0, sink, 0); | ||||
|         top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); | ||||
|     }) << "Failure connecting the blocks of tracking test." << std::endl; | ||||
|     }) << "Failure connecting the blocks of tracking test."; | ||||
|  | ||||
|     tracking->start_tracking(); | ||||
|  | ||||
|     EXPECT_NO_THROW( { | ||||
|         gettimeofday(&tv, NULL); | ||||
|         begin = tv.tv_sec *1000000 + tv.tv_usec; | ||||
|         start = std::chrono::system_clock::now(); | ||||
|         top_block->run(); // Start threads and wait | ||||
|         gettimeofday(&tv, NULL); | ||||
|         end = tv.tv_sec *1000000 + tv.tv_usec; | ||||
|     }) << "Failure running the top_block." << std::endl; | ||||
|         end = std::chrono::system_clock::now(); | ||||
|         elapsed_seconds = end - start; | ||||
|     }) << "Failure running the top_block."; | ||||
|  | ||||
|     // TODO: Verify tracking results | ||||
|     std::cout <<  "Tracked " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; | ||||
|     std::cout <<  "Tracked " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez