| 571 | } |
| 572 | |
| 573 | void 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; |
nothing calls this directly
no test coverage detected