MCPcopy Create free account
hub / github.com/KDE/labplot / testBenchmark

Method testBenchmark

tests/backend/gsl/ExpressionParserTest.cpp:573–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573void ExpressionParserTest::testBenchmark() {
574 const QString expr = QStringLiteral("atan2(x;y) + sqrt(x)");
575 const QStringList vars = {QStringLiteral("x"), QStringLiteral("y")};
576
577 const int values = 3000;
578
579 {
580 QVector<QVector<double>*> xVectors;
581
582 auto* x = new QVector<double>(values);
583 auto* y = new QVector<double>(values);
584 for (int i = 0; i < values; i++) {
585 if (i % 2 == 0) {
586 x->operator[](i) = 5.;
587 y->operator[](i) = 2.;
588 } else {
589 x->operator[](i) = 24.;
590 y->operator[](i) = 22.;
591 }
592 }
593
594 xVectors << x; // x
595 xVectors << y; // y
596 QVector<double> yVector(values); // random value
597 QBENCHMARK {
598 auto* parser = ExpressionParser::getInstance();
599 parser->tryEvaluateCartesian(expr, vars, xVectors, &yVector, true);
600 }
601 // QCOMPARE(QLatin1String(Parsing::lastErrorMessage()), QStringLiteral(""));
602
603 QCOMPARE(yVector.size(), values);
604 for (int i = 0; i < values; i++) {
605 if (i % 2 == 0) {
606 VALUES_EQUAL(yVector.at(i), 3.42635792718232);
607 } else {
608 VALUES_EQUAL(yVector.at(i), 5.72782854435533);
609 }
610 }
611 }
612
613 {
614 QVector<QVector<double>*> xVectors;

Callers

nothing calls this directly

Calls 3

operator[]Method · 0.80
tryEvaluateCartesianMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected