From 39c43ef8abe609afa911b419be4d02afa9bd8f30 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Mon, 18 Nov 2019 16:46:15 +0100 Subject: [PATCH] improved speedtest example (context-menu now allows to select the different options) and updated performance table for a newer processor --- examples/speed/README.md | 17 ++++++++- examples/speed/speedtestplot.cpp | 65 ++++++++++++++++++++++---------- examples/speed/speedtestplot.h | 4 ++ 3 files changed, 65 insertions(+), 21 deletions(-) diff --git a/examples/speed/README.md b/examples/speed/README.md index 32c6973897..73ebfa3f8c 100644 --- a/examples/speed/README.md +++ b/examples/speed/README.md @@ -65,7 +65,7 @@ There are different facor affecting the replot speed: 3. *Axis Scales and Plot Appearance:* Replotting is done in two steps: First the plot with the axes, labels etc. is drawn. Then the graphs are draw on top. Therefore a replot is faster, if only the graphs change, because the background (plot) does not have to be replotted. -the next table summarizes some results for plotting speed under different conditions, obatined with the test program in this directory (conditions: Qt 5.11, 32-bit, MinGW, Release, Phenom II X4 765, 500 data points): +The next table summarizes some results for plotting speed under different conditions, obatined with the test program in this directory (conditions: Qt 5.11, 32-bit, MinGW, Release, Win7, Phenom II X4 765, 500 data points): | Anti-Aliasing | X-Axis Redraw | # Graphs | frame rate [fps] | | ---------------- | --------------- | ------------- | ---------------- | @@ -80,3 +80,18 @@ the next table summarizes some results for plotting speed under different condit +Rerunning this test on a modern AMD Ryzen 3600 (conditions: Qt 5.13.1, 64-bit, MinGW, Release, AMD Ryzen 3600, Win10, 500 data points): + +| Anti-Aliasing | X-Axis Redraw | # Graphs | frame rate [fps] | +| ---------------- | --------------- | ------------- | ---------------- | +| yes | yes | 2 | 7 | +| yes | yes | 1 | 14 | +| yes | no | 2 | 14 | +| yes | no | 1 | 28 | +| no | yes | 2 | 30 | +| no | yes | 1 | 52 | +| no | no | 2 | 59 | +| no | no | 1 | 100 | + + + diff --git a/examples/speed/speedtestplot.cpp b/examples/speed/speedtestplot.cpp index c832f98888..fbb9f87357 100644 --- a/examples/speed/speedtestplot.cpp +++ b/examples/speed/speedtestplot.cpp @@ -54,6 +54,30 @@ SpeedTestPlot::SpeedTestPlot(): setX(X[0], X[NDATA-1]); setY(-2,2); + actAntiAliase=new QAction("Anti-Aliase"); + actAntiAliase->setCheckable(true); + actAntiAliase->setChecked(false); + connect(actAntiAliase, &QAction::triggered, std::bind([](SpeedTestPlot* p){ + p->getPlotter()->setUseAntiAliasingForGraphs(p->actAntiAliase->isChecked()); + p->getPlotter()->setUseAntiAliasingForSystem(p->actAntiAliase->isChecked()); + p->getPlotter()->setUseAntiAliasingForText(p->actAntiAliase->isChecked()); + }, this)); + + actTwoGraphs=new QAction("2 Graphs"); + actTwoGraphs->setCheckable(true); + actTwoGraphs->setChecked(true); + connect(actTwoGraphs, &QAction::triggered, std::bind([](SpeedTestPlot* p, JKQTPXYLineGraph* g){ + g->setVisible(p->actTwoGraphs->isChecked()); + }, this, graph2)); + + actFixedXAxis=new QAction("Fixed X-Axis"); + actFixedXAxis->setCheckable(true); + actFixedXAxis->setChecked(false); + + addAction(actAntiAliase); + addAction(actTwoGraphs); + addAction(actFixedXAxis); + // show plotter and make it a decent size show(); resize(1000,500); @@ -66,28 +90,29 @@ SpeedTestPlot::~SpeedTestPlot() void SpeedTestPlot::plotNewData() { - // move old data to the left - for (size_t i=0; i(std::rand())/static_cast(RAND_MAX + 1u)-0.5; - Y2[NDATA-1]=cos(X[NDATA-1])+static_cast(std::rand())/static_cast(RAND_MAX + 1u)-0.5; + if (actFixedXAxis->isChecked()) { + // ALTERNATIVE: MOVE data, but keep x-axis range + x0+=dx; + for (size_t i=0; i(std::rand())/static_cast(RAND_MAX + 1u)-0.5; + Y2[NDATA-1]=cos(X[NDATA-1]+x0)+static_cast(std::rand())/static_cast(RAND_MAX + 1u)-0.5; + } else { + // move old data to the left + for (size_t i=0; i(std::rand())/static_cast(RAND_MAX + 1u)-0.5; + Y2[NDATA-1]=cos(X[NDATA-1])+static_cast(std::rand())/static_cast(RAND_MAX + 1u)-0.5; - /* - // ALTERNATIVE: MOVE data, but keep x-axis range - x0+=dx; - for (size_t i=0; i(std::rand())/static_cast(RAND_MAX + 1u)-0.5; - Y2[NDATA-1]=cos(X[NDATA-1]+x0)+static_cast(std::rand())/static_cast(RAND_MAX + 1u)-0.5; - */ // set new x-range and replot diff --git a/examples/speed/speedtestplot.h b/examples/speed/speedtestplot.h index 1680acfa9f..cc229b5ff8 100644 --- a/examples/speed/speedtestplot.h +++ b/examples/speed/speedtestplot.h @@ -15,10 +15,14 @@ class SpeedTestPlot: public JKQTPlotter { const double dx; double x0; std::chrono::system_clock::time_point t_lastplot; + QAction* actAntiAliase; + QAction* actTwoGraphs; + QAction* actFixedXAxis; public: SpeedTestPlot(); virtual ~SpeedTestPlot(); public slots: void plotNewData(); + };