mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-11-15 18:15:52 +08:00
NEW: Added CMake option JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT, which activates several runtime-measurement guards of type JKQTPAutoOutputTimer (output via qDebug())
This commit is contained in:
parent
b02db2eb93
commit
3fee9609fb
@ -25,6 +25,9 @@ endif()
|
|||||||
if(NOT DEFINED JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
if(NOT DEFINED JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
||||||
option(JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS "Build the library using precompiled headers to improve compile speed" ON)
|
option(JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS "Build the library using precompiled headers to improve compile speed" ON)
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT DEFINED JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT)
|
||||||
|
option(JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT "Build the library to output extra timing information using Debug()" OFF)
|
||||||
|
endif()
|
||||||
if(NOT DEFINED JKQtPlotter_ENABLED_CXX20)
|
if(NOT DEFINED JKQtPlotter_ENABLED_CXX20)
|
||||||
option(JKQtPlotter_ENABLED_CXX20 "Build the library using C++20" OFF)
|
option(JKQtPlotter_ENABLED_CXX20 "Build the library using C++20" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
@ -24,11 +24,21 @@ if(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
|
|||||||
else()
|
else()
|
||||||
message( STATUS "XITS fonts: NOT AVAILABLE IN LIB" )
|
message( STATUS "XITS fonts: NOT AVAILABLE IN LIB" )
|
||||||
endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
|
endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
|
||||||
|
if(JKQtPlotter_BUILD_INCLUDE_FIRAMATH_FONTS)
|
||||||
|
message( STATUS "FIRA fonts: LINKED IN" )
|
||||||
|
else()
|
||||||
|
message( STATUS "FIRA fonts: NOT AVAILABLE IN LIB" )
|
||||||
|
endif(JKQtPlotter_BUILD_INCLUDE_FIRAMATH_FONTS)
|
||||||
if(${JKQtPlotter_HAS_NO_PRINTER_SUPPORT})
|
if(${JKQtPlotter_HAS_NO_PRINTER_SUPPORT})
|
||||||
message( STATUS "Print support: OFF" )
|
message( STATUS "Print support: OFF" )
|
||||||
else()
|
else()
|
||||||
message( STATUS "Print support: ON" )
|
message( STATUS "Print support: ON" )
|
||||||
endif()
|
endif()
|
||||||
|
if(${JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT})
|
||||||
|
message( STATUS "Timing Info output: OFF" )
|
||||||
|
else()
|
||||||
|
message( STATUS "Timing Info output: ON" )
|
||||||
|
endif()
|
||||||
if (JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
if (JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
||||||
message( STATUS "Precompiled Header: ON" )
|
message( STATUS "Precompiled Header: ON" )
|
||||||
else()
|
else()
|
||||||
|
@ -81,6 +81,10 @@ function(JKQtCommon_setDefaultLibOptions TARGETNAME)
|
|||||||
target_compile_options(${TARGETNAME} PUBLIC /EHsc)
|
target_compile_options(${TARGETNAME} PUBLIC /EHsc)
|
||||||
target_compile_definitions(${TARGETNAME} PUBLIC NOMINMAX)
|
target_compile_definitions(${TARGETNAME} PUBLIC NOMINMAX)
|
||||||
endif()
|
endif()
|
||||||
|
if(JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT)
|
||||||
|
target_compile_definitions(${TARGETNAME} PRIVATE JKQTBP_AUTOTIMER)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(${TARGETNAME} PUBLIC
|
target_include_directories(${TARGETNAME} PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
|
@ -148,6 +148,9 @@ function(JKQtMathText_setDefaultLibOptions TARGETNAME)
|
|||||||
if(JKQtPlotter_BUILD_INCLUDE_FIRAMATH_FONTS)
|
if(JKQtPlotter_BUILD_INCLUDE_FIRAMATH_FONTS)
|
||||||
target_compile_definitions(${TARGETNAME} PRIVATE JKQTMATHTEXT_COMPILED_WITH_FIRAMATH)
|
target_compile_definitions(${TARGETNAME} PRIVATE JKQTMATHTEXT_COMPILED_WITH_FIRAMATH)
|
||||||
endif(JKQtPlotter_BUILD_INCLUDE_FIRAMATH_FONTS)
|
endif(JKQtPlotter_BUILD_INCLUDE_FIRAMATH_FONTS)
|
||||||
|
if(JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT)
|
||||||
|
target_compile_definitions(${TARGETNAME} PRIVATE JKQTBP_AUTOTIMER)
|
||||||
|
endif()
|
||||||
|
|
||||||
# precomiled headers to speed up compilation
|
# precomiled headers to speed up compilation
|
||||||
if (JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
if (JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "jkqtmathtext/nodes/jkqtmathtextnode.h"
|
#include "jkqtmathtext/nodes/jkqtmathtextnode.h"
|
||||||
#include "jkqtcommon/jkqtpcodestructuring.h"
|
#include "jkqtcommon/jkqtpcodestructuring.h"
|
||||||
#include "jkqtcommon/jkqtpstringtools.h"
|
#include "jkqtcommon/jkqtpstringtools.h"
|
||||||
|
#include "jkqtcommon/jkqtpdebuggingtools.h"
|
||||||
#include "jkqtmathtext/nodes/jkqtmathtextnodetools.h"
|
#include "jkqtmathtext/nodes/jkqtmathtextnodetools.h"
|
||||||
#include "jkqtmathtext/nodes/jkqtmathtexttextnode.h"
|
#include "jkqtmathtext/nodes/jkqtmathtexttextnode.h"
|
||||||
#include "jkqtmathtext/nodes/jkqtmathtextbracenode.h"
|
#include "jkqtmathtext/nodes/jkqtmathtextbracenode.h"
|
||||||
@ -297,6 +298,9 @@ void JKQTMathText::saveSettings(QSettings& settings, const QString& group) const
|
|||||||
|
|
||||||
bool JKQTMathText::parse(const QString &markup, DefaultParserTypes markupType, ParseOptions options)
|
bool JKQTMathText::parse(const QString &markup, DefaultParserTypes markupType, ParseOptions options)
|
||||||
{
|
{
|
||||||
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
|
JKQTPAutoOutputTimer jkaat(QString("JKQTMathText[%1]::parse('%2')").arg(objectName()).arg(markup));
|
||||||
|
#endif
|
||||||
if (markupType==LatexParser) return parse<JKQTMathTextLatexParser>(markup, options);
|
if (markupType==LatexParser) return parse<JKQTMathTextLatexParser>(markup, options);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1250,6 +1254,9 @@ void JKQTMathText::modifyEnvironmentFromFontSettings(JKQTMathTextEnvironment &ev
|
|||||||
|
|
||||||
JKQTMathTextNodeSize JKQTMathText::getSizeDetail(QPainter &painter)
|
JKQTMathTextNodeSize JKQTMathText::getSizeDetail(QPainter &painter)
|
||||||
{
|
{
|
||||||
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
|
JKQTPAutoOutputTimer jkaat(QString("JKQTMathText[%1]::getSizeDetail()").arg(objectName()));
|
||||||
|
#endif
|
||||||
JKQTMathTextNodeSize s;
|
JKQTMathTextNodeSize s;
|
||||||
if (getNodeTree()!=nullptr) {
|
if (getNodeTree()!=nullptr) {
|
||||||
JKQTMathTextEnvironment ev;
|
JKQTMathTextEnvironment ev;
|
||||||
@ -1265,6 +1272,9 @@ void JKQTMathText::draw(QPainter &painter, QPointF x, bool drawBoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
double JKQTMathText::draw(QPainter& painter, double x, double y, bool drawBoxes){
|
double JKQTMathText::draw(QPainter& painter, double x, double y, bool drawBoxes){
|
||||||
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
|
JKQTPAutoOutputTimer jkaat(QString("JKQTMathText[%1]::draw(x,y)").arg(objectName()));
|
||||||
|
#endif
|
||||||
if (getNodeTree()!=nullptr) {
|
if (getNodeTree()!=nullptr) {
|
||||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
painter.setPen(fontColor);
|
painter.setPen(fontColor);
|
||||||
@ -1279,6 +1289,9 @@ double JKQTMathText::draw(QPainter& painter, double x, double y, bool drawBoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JKQTMathText::draw(QPainter& painter, unsigned int flags, QRectF rect, bool drawBoxes) {
|
void JKQTMathText::draw(QPainter& painter, unsigned int flags, QRectF rect, bool drawBoxes) {
|
||||||
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
|
JKQTPAutoOutputTimer jkaat(QString("JKQTMathText[%1]::draw(rect)").arg(objectName()));
|
||||||
|
#endif
|
||||||
if (getNodeTree()!=nullptr) {
|
if (getNodeTree()!=nullptr) {
|
||||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||||
painter.setPen(fontColor);
|
painter.setPen(fontColor);
|
||||||
@ -1309,6 +1322,9 @@ void JKQTMathText::draw(QPainter& painter, unsigned int flags, QRectF rect, bool
|
|||||||
|
|
||||||
QPixmap JKQTMathText::drawIntoPixmap(bool drawBoxes, QColor backgroundColor, int sizeincrease, qreal devicePixelRatio)
|
QPixmap JKQTMathText::drawIntoPixmap(bool drawBoxes, QColor backgroundColor, int sizeincrease, qreal devicePixelRatio)
|
||||||
{
|
{
|
||||||
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
|
JKQTPAutoOutputTimer jkaat(QString("JKQTMathText[%1]::drawIntoPixmap()").arg(objectName()));
|
||||||
|
#endif
|
||||||
// 1. generate dummy QPixmap that is needed to use a QPainter
|
// 1. generate dummy QPixmap that is needed to use a QPainter
|
||||||
// we need the dummy, because we first need to determine the size of the render output
|
// we need the dummy, because we first need to determine the size of the render output
|
||||||
// for which we need a QPainter.
|
// for which we need a QPainter.
|
||||||
@ -1351,6 +1367,9 @@ QPixmap JKQTMathText::drawIntoPixmap(bool drawBoxes, QColor backgroundColor, int
|
|||||||
|
|
||||||
QImage JKQTMathText::drawIntoImage(bool drawBoxes, QColor backgroundColor, int sizeincrease, qreal devicePixelRatio, unsigned int resolution_dpi)
|
QImage JKQTMathText::drawIntoImage(bool drawBoxes, QColor backgroundColor, int sizeincrease, qreal devicePixelRatio, unsigned int resolution_dpi)
|
||||||
{
|
{
|
||||||
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
|
JKQTPAutoOutputTimer jkaat(QString("JKQTMathText[%1]::drawIntoImage()").arg(objectName()));
|
||||||
|
#endif
|
||||||
// 1. generate dummy QPixmap that is needed to use a QPainter
|
// 1. generate dummy QPixmap that is needed to use a QPainter
|
||||||
// we need the dummy, because we first need to determine the size of the render output
|
// we need the dummy, because we first need to determine the size of the render output
|
||||||
// for which we need a QPainter.
|
// for which we need a QPainter.
|
||||||
@ -1397,6 +1416,9 @@ QImage JKQTMathText::drawIntoImage(bool drawBoxes, QColor backgroundColor, int s
|
|||||||
|
|
||||||
QPicture JKQTMathText::drawIntoPicture(bool drawBoxes)
|
QPicture JKQTMathText::drawIntoPicture(bool drawBoxes)
|
||||||
{
|
{
|
||||||
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
|
JKQTPAutoOutputTimer jkaat(QString("JKQTMathText[%1]::drawIntoPicture()").arg(objectName()));
|
||||||
|
#endif
|
||||||
// 1. generate dummy QPixmap that is needed to use a QPainter
|
// 1. generate dummy QPixmap that is needed to use a QPainter
|
||||||
// we need the dummy, because we first need to determine the size of the render output
|
// we need the dummy, because we first need to determine the size of the render output
|
||||||
// for which we need a QPainter.
|
// for which we need a QPainter.
|
||||||
|
@ -208,7 +208,9 @@ function(JKQtPlottter_setDefaultLibOptions TARGETNAME)
|
|||||||
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD ${JKQtPlotter_QT_CXX_STANDARD})
|
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD ${JKQtPlotter_QT_CXX_STANDARD})
|
||||||
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED ${JKQtPlotter_QT_CXX_STANDARD_REQUIRED})
|
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED ${JKQtPlotter_QT_CXX_STANDARD_REQUIRED})
|
||||||
target_compile_features(${TARGETNAME} PUBLIC ${JKQtPlotter_QT_CXX_COMPILE_FEATURE})
|
target_compile_features(${TARGETNAME} PUBLIC ${JKQtPlotter_QT_CXX_COMPILE_FEATURE})
|
||||||
#target_compile_definitions(${TARGETNAME} PRIVATE JKQTBP_AUTOTIMER)
|
if(JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT)
|
||||||
|
target_compile_definitions(${TARGETNAME} PRIVATE JKQTBP_AUTOTIMER)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
# COMPILER-SETTINGS FOR MINGW
|
# COMPILER-SETTINGS FOR MINGW
|
||||||
|
@ -127,8 +127,13 @@ JKQTMathTextNodeSize JKQTBasePlotter::getTextSizeDetail(const QFont &fm, const Q
|
|||||||
|
|
||||||
JKQTMathTextNodeSize JKQTBasePlotter::getTextSizeDetail(const QString &fontName, double fontSize, const QString &text, QPainter& painter)
|
JKQTMathTextNodeSize JKQTBasePlotter::getTextSizeDetail(const QString &fontName, double fontSize, const QString &text, QPainter& painter)
|
||||||
{
|
{
|
||||||
thread_local QHash<JKQTBasePlotter::textSizeKey, JKQTMathTextNodeSize> s_TextSizeDataCache;
|
|
||||||
JKQTBasePlotter::textSizeKey dh(fontName, fontSize, text, painter.device());
|
JKQTBasePlotter::textSizeKey dh(fontName, fontSize, text, painter.device());
|
||||||
|
static QReadWriteLock s_TextSizeLock;
|
||||||
|
thread_local QHash<JKQTBasePlotter::textSizeKey, JKQTMathTextNodeSize> s_TextSizeDataCache;
|
||||||
|
QReadLocker lockR(&s_TextSizeLock);
|
||||||
|
if (s_TextSizeDataCache.contains(dh)) return s_TextSizeDataCache[dh];
|
||||||
|
lockR.unlock();
|
||||||
|
QWriteLocker lockW(&s_TextSizeLock);
|
||||||
if (s_TextSizeDataCache.contains(dh)) return s_TextSizeDataCache[dh];
|
if (s_TextSizeDataCache.contains(dh)) return s_TextSizeDataCache[dh];
|
||||||
mathText.setFontSpecial(fontName);
|
mathText.setFontSpecial(fontName);
|
||||||
mathText.setFontSize(fontSize);
|
mathText.setFontSize(fontSize);
|
||||||
@ -863,6 +868,9 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
|
|||||||
// this needs to be done twice, as the kay size calculation needs the internalPlotWidth and internalPlotHeight
|
// this needs to be done twice, as the kay size calculation needs the internalPlotWidth and internalPlotHeight
|
||||||
// for a second step
|
// for a second step
|
||||||
for (int i=0; i<2; i++) {
|
for (int i=0; i<2; i++) {
|
||||||
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
|
JKQTPAutoOutputTimer jkaat(QString("JKQTBasePlotter[%1]::calcPlotScaling()::iteration%2").arg(objectName()).arg(i+1));
|
||||||
|
#endif
|
||||||
|
|
||||||
internalPlotMargins[PlotMarginUse::muKey]=PlotMargin();
|
internalPlotMargins[PlotMarginUse::muKey]=PlotMargin();
|
||||||
switch(internalPlotKeyDescription.keyLocation) {
|
switch(internalPlotKeyDescription.keyLocation) {
|
||||||
@ -1252,7 +1260,7 @@ void JKQTBasePlotter::drawPlotLabel(JKQTPEnhancedPainter& painter) {
|
|||||||
|
|
||||||
void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter) {
|
void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter) {
|
||||||
#ifdef JKQTBP_AUTOTIMER
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::paintPlot");
|
JKQTPAutoOutputTimer jkaaot("JKQTBasePlotter::drawPlot()");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if QT_VERSION<QT_VERSION_CHECK(6,0,0)
|
#if QT_VERSION<QT_VERSION_CHECK(6,0,0)
|
||||||
@ -3752,9 +3760,11 @@ bool JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPrev
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!displayPreview || exportpreview(gridPrintingSize, false)) {
|
if (!displayPreview || exportpreview(gridPrintingSize, false)) {
|
||||||
|
QElapsedTimer timer;
|
||||||
|
timer.start();
|
||||||
QImage png(QSizeF(double(printSizeX_Millimeter)+outputSizeIncrease.width(), double(printSizeY_Millimeter)+outputSizeIncrease.height()).toSize(), QImage::Format_ARGB32);
|
QImage png(QSizeF(double(printSizeX_Millimeter)+outputSizeIncrease.width(), double(printSizeY_Millimeter)+outputSizeIncrease.height()).toSize(), QImage::Format_ARGB32);
|
||||||
png.fill(Qt::transparent);
|
png.fill(Qt::transparent);
|
||||||
|
const double durPrepImage=timer.nsecsElapsed();
|
||||||
{
|
{
|
||||||
JKQTPEnhancedPainter painter;
|
JKQTPEnhancedPainter painter;
|
||||||
painter.begin(&png);
|
painter.begin(&png);
|
||||||
@ -3772,8 +3782,14 @@ bool JKQTBasePlotter::saveAsPixelImage(const QString& filename, bool displayPrev
|
|||||||
exportpreviewPaintRequested(painter, QSize(jkqtp_roundTo<int>(printSizeX_Millimeter), jkqtp_roundTo<int>(printSizeY_Millimeter)));
|
exportpreviewPaintRequested(painter, QSize(jkqtp_roundTo<int>(printSizeX_Millimeter), jkqtp_roundTo<int>(printSizeY_Millimeter)));
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
if (form=="NONE") return png.save(fn);
|
const double durPlot=timer.nsecsElapsed()-durPrepImage;
|
||||||
else return png.save(fn, form.toLatin1().data());
|
bool res=false;
|
||||||
|
if (form=="NONE") res= png.save(fn);
|
||||||
|
else res= png.save(fn, form.toLatin1().data());
|
||||||
|
const double durAll=timer.nsecsElapsed();
|
||||||
|
const double durSave=durAll-durPlot;
|
||||||
|
qDebug()<<"durPrepImage="<<durPrepImage/1e6<<"ms, durPlot="<<durPlot/1e6<<"ms, durSave="<<durSave/1e6<<"ms, durAll="<<durAll/1e6<<"ms";
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,7 @@ int JKQTPCoordinateAxis::calcLinearUnitDigits() {
|
|||||||
|
|
||||||
void JKQTPCoordinateAxis::calcPlotScaling(bool force) {
|
void JKQTPCoordinateAxis::calcPlotScaling(bool force) {
|
||||||
#ifdef JKQTBP_AUTOTIMER
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
JKQTPAutoOutputTimer jkaat(QString("JKQTBasePlotter[%1]::calcPlotScaling()").arg(objectName()));
|
JKQTPAutoOutputTimer jkaat(QString("JKQTPCoordinateAxis[%1]::calcPlotScaling()").arg(objectName()));
|
||||||
#endif
|
#endif
|
||||||
if (!doUpdateScaling) return;
|
if (!doUpdateScaling) return;
|
||||||
if (!force && !paramsChanged) return;
|
if (!force && !paramsChanged) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user