MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / runDataPipeline

Method runDataPipeline

app/src/Benchmark/HotpathBenchmark.cpp:500–558  ·  view source on GitHub ↗

* @brief Measures raw FrameReader extraction throughput (the driver pipeline, no parse). */

Source from the content-addressed store, hash-verified

498 * @brief Measures raw FrameReader extraction throughput (the driver pipeline, no parse).
499 */
500HotpathBenchmark::Result HotpathBenchmark::runDataPipeline(quint64 targetFrames,
501 double minFps,
502 double minSeconds)
503{
504 Q_ASSERT(targetFrames > 0);
505 Q_ASSERT(minFps > 0.0);
506 Q_ASSERT(minSeconds >= 0.0);
507
508 constexpr int kChannels = 8;
509 constexpr int kFramesPerChunk = 1000;
510
511 const QByteArray chunk = buildChunk(kFramesPerChunk, kChannels);
512
513 IO::FrameReader reader;
514 reader.setOperationMode(SerialStudio::QuickPlot);
515 reader.setFinishSequences({QByteArrayLiteral("\n")});
516
517 auto& queue = reader.queue();
518 IO::CapturedDataPtr drained;
519
520 using Clock = std::chrono::steady_clock;
521 const quint64 maxFrames = targetFrames + static_cast<quint64>(minSeconds * 1.0e9);
522 const quint64 maxChunks = maxFrames / kFramesPerChunk + 1;
523
524 quint64 extracted = 0;
525 quint64 fed = 0;
526 double seconds = 0.0;
527 double spentSpin = 0.0;
528 double lastSpin = 0.0;
529 const auto start = Clock::now();
530 for (quint64 c = 0; c < maxChunks && (fed < targetFrames || seconds < minSeconds); ++c) {
531 reader.processData(IO::makeCapturedData(chunk));
532
533 // code-verify off
534 while (queue.try_dequeue(drained))
535 ++extracted;
536 // code-verify on
537
538 fed += kFramesPerChunk;
539 seconds = std::chrono::duration<double>(Clock::now() - start).count() - spentSpin;
540
541 if (seconds - lastSpin >= kSpinIntervalSec) {
542 spentSpin += spinEventLoop();
543 lastSpin = seconds;
544 }
545 }
546
547 const double fps = seconds > 0.0 ? static_cast<double>(extracted) / seconds : 0.0;
548
549 Result result;
550 result.passed = fps >= minFps;
551 result.language = -1;
552 result.minFps = minFps;
553 result.framesPerSecond = fps;
554 result.elapsedSeconds = seconds;
555 result.framesParsed = extracted;
556 result.framesSkipped = 0;
557 return result;

Callers

nothing calls this directly

Calls 7

makeCapturedDataFunction · 0.85
spinEventLoopFunction · 0.85
setFinishSequencesMethod · 0.80
setOperationModeMethod · 0.45
processDataMethod · 0.45
try_dequeueMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected