@@ -306,18 +306,22 @@ void CharConvert<T>::Convert(const std::string data, T& convertedData, Header co
306
306
}
307
307
308
308
size_t countDecimalPlaces (double value) {
309
- // Convert double to string
310
309
std::string str = std::to_string (value);
310
+ auto dotPos = str.find (' .' );
311
+ if (dotPos == std::string::npos) return 0 ;
311
312
312
- char const * a = str.c_str ();
313
+ // Get the decimal part
314
+ std::string decimals = str.substr (dotPos + 1 );
313
315
314
- double testNumber = 0.0 ;
315
- double goldNumber = 0.0 ;
316
- int testSucceededCount = sscanf_s (a, " %lf" , &testNumber);
316
+ // Remove trailing zeros
317
+ decimals.erase (decimals.find_last_not_of (' 0' ) + 1 );
317
318
318
- const char * testDecimalAddr = strchr (a, ' .' );
319
- size_t testDecimalNumbersCount = testDecimalAddr == nullptr ? 0 : ((a + strlen (a)) - testDecimalAddr - 1 );
320
- return testDecimalNumbersCount;
319
+ // Count non-zero decimal digits
320
+ size_t count = 0 ;
321
+ for (char c : decimals) {
322
+ if (c != ' 0' ) ++count;
323
+ }
324
+ return count;
321
325
}
322
326
323
327
template <typename T>
@@ -357,7 +361,7 @@ std::optional<std::ofstream> CreateCsvFile(std::string& output_dir, std::string&
357
361
" ,MsBetweenDisplayChange,MsInPresent,MsRenderPresentLatency"
358
362
" ,MsUntilDisplayed,MsPCLatency,CPUStartQPC,MsBetweenAppStart"
359
363
" ,MsCPUBusy,MsCPUWait,MsGPULatency,MsGPUTime,MsGPUBusy,MsGPUWait"
360
- " ,MsVideoBusy,MsAnimationError,AnimationTime,MsAllInputToPhotonLatency"
364
+ " ,MsVideoBusy,MsAnimationError,AnimationTime,MsFlipDelay, MsAllInputToPhotonLatency"
361
365
" ,MsClickToPhotonLatency,MsInstrumentedLatency" ;
362
366
csvFile << std::endl;
363
367
return csvFile;
@@ -416,7 +420,7 @@ std::string TranslateFrameType(PM_FRAME_TYPE frameType) {
416
420
}
417
421
418
422
void WriteToCSV (std::optional<std::ofstream>& debugCsvFile, const std::string& processName, const unsigned int & processId,
419
- PM_QUERY_ELEMENT (&queryElements)[28 ], pmapi::BlobContainer& blobs)
423
+ PM_QUERY_ELEMENT (&queryElements)[29 ], pmapi::BlobContainer& blobs)
420
424
{
421
425
422
426
if (!debugCsvFile.has_value ()) {
@@ -449,9 +453,10 @@ void WriteToCSV(std::optional<std::ofstream>& debugCsvFile, const std::string& p
449
453
const auto msGpuWait = *reinterpret_cast <const double *>(&pBlob[queryElements[22 ].dataOffset ]);
450
454
const auto msAnimationError = *reinterpret_cast <const double *>(&pBlob[queryElements[23 ].dataOffset ]);
451
455
const auto animationTime = *reinterpret_cast <const double *>(&pBlob[queryElements[24 ].dataOffset ]);
452
- const auto msAllInputToPhotonLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[25 ].dataOffset ]);
453
- const auto msClickToPhotonLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[26 ].dataOffset ]);
454
- const auto msInstrumentedLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[27 ].dataOffset ]);
456
+ const auto msFlipDelay = *reinterpret_cast <const double *>(&pBlob[queryElements[25 ].dataOffset ]);
457
+ const auto msAllInputToPhotonLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[26 ].dataOffset ]);
458
+ const auto msClickToPhotonLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[27 ].dataOffset ]);
459
+ const auto msInstrumentedLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[28 ].dataOffset ]);
455
460
*debugCsvFile << processName << " ," ;
456
461
*debugCsvFile << processId << " ," ;
457
462
*debugCsvFile << std::hex << " 0x" << std::dec << swapChain << " ," ;
@@ -480,6 +485,7 @@ void WriteToCSV(std::optional<std::ofstream>& debugCsvFile, const std::string& p
480
485
*debugCsvFile << 0 << " ," ;
481
486
*debugCsvFile << msAnimationError << " ," ;
482
487
*debugCsvFile << animationTime << " ," ;
488
+ *debugCsvFile << msFlipDelay << " ," ;
483
489
*debugCsvFile << msAllInputToPhotonLatency << " ," ;
484
490
*debugCsvFile << msClickToPhotonLatency << " ," ;
485
491
*debugCsvFile << msInstrumentedLatency << std::endl;
@@ -497,7 +503,7 @@ class CsvParser {
497
503
bool Open (std::wstring const & path, uint32_t processId);
498
504
void Close ();
499
505
bool VerifyBlobAgainstCsv (const std::string& processName, const unsigned int & processId,
500
- PM_QUERY_ELEMENT (&queryElements)[28 ], pmapi::BlobContainer& blobs, std::optional<std::ofstream>& debugCsvFile);
506
+ PM_QUERY_ELEMENT (&queryElements)[29 ], pmapi::BlobContainer& blobs, std::optional<std::ofstream>& debugCsvFile);
501
507
bool ResetCsv ();
502
508
503
509
private:
@@ -526,7 +532,7 @@ CsvParser::CsvParser()
526
532
{}
527
533
528
534
bool CsvParser::VerifyBlobAgainstCsv (const std::string& processName, const unsigned int & processId,
529
- PM_QUERY_ELEMENT (&queryElements)[28 ], pmapi::BlobContainer& blobs, std::optional<std::ofstream>& debugCsvFile)
535
+ PM_QUERY_ELEMENT (&queryElements)[29 ], pmapi::BlobContainer& blobs, std::optional<std::ofstream>& debugCsvFile)
530
536
{
531
537
if (debugCsvFile.has_value ()) {
532
538
WriteToCSV (debugCsvFile, processName, processId, queryElements, blobs);
@@ -559,11 +565,10 @@ bool CsvParser::VerifyBlobAgainstCsv(const std::string& processName, const unsig
559
565
const auto msGpuWait = *reinterpret_cast <const double *>(&pBlob[queryElements[22 ].dataOffset ]);
560
566
const auto msAnimationError = *reinterpret_cast <const double *>(&pBlob[queryElements[23 ].dataOffset ]);
561
567
const auto animationTime = *reinterpret_cast <const double *>(&pBlob[queryElements[24 ].dataOffset ]);
562
- const auto msAllInputToPhotonLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[25 ].dataOffset ]);
563
- const auto msClickToPhotonLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[26 ].dataOffset ]);
564
- const auto msInstrumentedLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[27 ].dataOffset ]);
565
-
566
-
568
+ const auto msFrameDelay = *reinterpret_cast <const double *>(&pBlob[queryElements[25 ].dataOffset ]);
569
+ const auto msAllInputToPhotonLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[26 ].dataOffset ]);
570
+ const auto msClickToPhotonLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[27 ].dataOffset ]);
571
+ const auto msInstrumentedLatency = *reinterpret_cast <const double *>(&pBlob[queryElements[28 ].dataOffset ]);
567
572
568
573
// Read rows until we find one with the process we are interested in
569
574
// or we are out of data.
@@ -689,6 +694,9 @@ bool CsvParser::VerifyBlobAgainstCsv(const std::string& processName, const unsig
689
694
case Header_MsPCLatency:
690
695
if (v2MetricRow_.msPcLatency .has_value ()) {
691
696
columnsMatch = Validate (v2MetricRow_.msPcLatency .value (), msPcLatency);
697
+ if (!columnsMatch) {
698
+ OutputDebugStringA (" What!?\n " );
699
+ }
692
700
}
693
701
else
694
702
{
@@ -780,6 +788,11 @@ bool CsvParser::VerifyBlobAgainstCsv(const std::string& processName, const unsig
780
788
columnsMatch = true ;
781
789
break ;
782
790
}
791
+ if (columnsMatch == false ) {
792
+ // If the columns do not match, create an error string
793
+ // and assert failure.
794
+ Assert::Fail (CreateErrorString (pair.second , line_).c_str ());
795
+ }
783
796
Assert::IsTrue (columnsMatch, CreateErrorString (pair.second , line_).c_str ());
784
797
}
785
798
}
@@ -1185,7 +1198,6 @@ void CsvParser::ConvertToMetricDataType(const char* data, Header columnId)
1185
1198
}
1186
1199
}
1187
1200
break ;
1188
-
1189
1201
default :
1190
1202
Assert::Fail (CreateErrorString (UnknownHeader, line_).c_str ());
1191
1203
}
0 commit comments