| 
									
										
										
										
											2015-05-24 06:55:12 +02:00
										 |  |  | // Copyright 2012 Dolphin Emulator Project
 | 
					
						
							| 
									
										
										
										
											2015-05-18 01:08:10 +02:00
										 |  |  | // Licensed under GPLv2+
 | 
					
						
							| 
									
										
										
										
											2013-04-17 23:09:55 -04:00
										 |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-02 20:19:08 -04:00
										 |  |  | #include <fstream>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 16:54:31 -05:00
										 |  |  | #include "Common/CommonTypes.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "Common/FileUtil.h"
 | 
					
						
							|  |  |  | #include "Common/Timer.h"
 | 
					
						
							|  |  |  | #include "VideoCommon/FPSCounter.h"
 | 
					
						
							|  |  |  | #include "VideoCommon/VideoConfig.h"
 | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-29 09:49:12 -04:00
										 |  |  | static constexpr u64 FPS_REFRESH_INTERVAL = 1000; | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-13 13:04:25 +02:00
										 |  |  | FPSCounter::FPSCounter() | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_update_time.Update(); | 
					
						
							|  |  |  |   m_render_time.Update(); | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-13 13:04:25 +02:00
										 |  |  | void FPSCounter::LogRenderTimeToFile(u64 val) | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (!m_bench_file.is_open()) | 
					
						
							|  |  |  |     m_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt"); | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_bench_file << val << std::endl; | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-29 09:57:54 -04:00
										 |  |  | void FPSCounter::Update() | 
					
						
							| 
									
										
										
										
											2012-10-04 05:41:02 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (m_update_time.GetTimeDifference() >= FPS_REFRESH_INTERVAL) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     m_update_time.Update(); | 
					
						
							|  |  |  |     m_fps = m_counter - m_fps_last_counter; | 
					
						
							|  |  |  |     m_fps_last_counter = m_counter; | 
					
						
							|  |  |  |     m_bench_file.flush(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (g_ActiveConfig.bLogRenderTimeToFile) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     LogRenderTimeToFile(m_render_time.GetTimeDifference()); | 
					
						
							|  |  |  |     m_render_time.Update(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   m_counter++; | 
					
						
							| 
									
										
										
										
											2014-07-02 20:19:08 -04:00
										 |  |  | } |