Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-07 08:47:25

0001 
0002 #include <catch.hpp>
0003 
0004 #include <JANA/JApplication.h>
0005 #include <JANA/JFactoryGenerator.h>
0006 #include <JANA/CLI/JBenchmarker.h>
0007 #include <JANA/JEventUnfolder.h>
0008 #include <JANA/JEventProcessor.h>
0009 #include <JANA/JEventSource.h>
0010 #include <JANA/Utils/JBenchUtils.h>
0011 
0012 
0013 namespace jana::perftest::source {
0014 
0015 struct Data { size_t x; };
0016 
0017 struct Src : public JEventSource {
0018 
0019     Parameter<int> latency_us {this, "latency_us", 0};
0020     Output<Data> data_out {this};
0021 
0022     Src() {
0023         SetPrefix("sut");
0024         SetCallbackStyle(CallbackStyle::ExpertMode);
0025         data_out.SetShortName("1");
0026     }
0027     JEventSource::Result Emit(JEvent& block) override {
0028         data_out().push_back(new Data {block.GetEventNumber()*3 });
0029         JBenchUtils::consume_cpu_us(*latency_us);
0030         return Result::Success;
0031     };
0032 };
0033 
0034 TEST_CASE("SourceTopology_Mini") {
0035     LOG << "Running SourceTopology_Mini";
0036     JApplication app;
0037     app.SetParameterValue("sut:latency_us", 0); // Infinity Hz
0038     app.SetParameterValue("benchmark:resultsdir", "docs/perf_tests");
0039     app.SetParameterValue("benchmark:rates_filename", "source_mini.dat");
0040     app.SetParameterValue("benchmark:use_log_scale", true);
0041     app.SetParameterValue("benchmark:minthreads", "1");
0042     app.SetParameterValue("benchmark:maxthreads", "32");
0043     app.Add(new Src);
0044     JBenchmarker benchmarker(&app);
0045     benchmarker.RunUntilFinished();
0046 }
0047 
0048 TEST_CASE("SourceTopology_Small") {
0049     LOG << "Running SourceTopology_Small";
0050     JApplication app;
0051     app.SetParameterValue("sut:latency_us", 50); // 20 kHz
0052     app.SetParameterValue("benchmark:resultsdir", "docs/perf_tests");
0053     app.SetParameterValue("benchmark:rates_filename", "source_small.dat");
0054     app.SetParameterValue("benchmark:use_log_scale", true);
0055     app.SetParameterValue("benchmark:minthreads", "1");
0056     app.SetParameterValue("benchmark:maxthreads", "32");
0057     app.Add(new Src);
0058     JBenchmarker benchmarker(&app);
0059     benchmarker.RunUntilFinished();
0060 }
0061 
0062 TEST_CASE("SourceTopology_Medium") {
0063     LOG << "Running SourceTopology_Medium";
0064     JApplication app;
0065     app.SetParameterValue("sut:latency_us", 10000); // 100 Hz
0066     app.SetParameterValue("benchmark:resultsdir", "docs/perf_tests");
0067     app.SetParameterValue("benchmark:rates_filename", "source_medium.dat");
0068     app.SetParameterValue("benchmark:use_log_scale", true);
0069     app.SetParameterValue("benchmark:minthreads", "1");
0070     app.SetParameterValue("benchmark:maxthreads", "32");
0071     app.Add(new Src);
0072     JBenchmarker benchmarker(&app);
0073     benchmarker.RunUntilFinished();
0074 }
0075 
0076 TEST_CASE("SourceTopology_Large") {
0077     LOG << "Running SourceTopology_Large";
0078     JApplication app;
0079     app.SetParameterValue("sut:latency_us", 200000); // 5 Hz
0080     app.SetParameterValue("benchmark:resultsdir", "docs/perf_tests");
0081     app.SetParameterValue("benchmark:rates_filename", "source_large.dat");
0082     app.SetParameterValue("benchmark:use_log_scale", true);
0083     app.SetParameterValue("benchmark:minthreads", "1");
0084     app.SetParameterValue("benchmark:maxthreads", "32");
0085     app.Add(new Src);
0086     JBenchmarker benchmarker(&app);
0087     benchmarker.RunUntilFinished();
0088 }
0089 
0090 }
0091 
0092 
0093