diff --git a/src/myx-cmake-example-features/main.cpp b/src/myx-cmake-example-features/main.cpp index 82f1c6f..bb8053d 100644 --- a/src/myx-cmake-example-features/main.cpp +++ b/src/myx-cmake-example-features/main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include /** @@ -29,6 +30,40 @@ int unused( int a ) } +/** + * \brief Медленная функция + */ +int slowFunction() +{ + constexpr int size = 16 * 1024; + double a[size]; + for ( int i = 0; i < size; i++ ) + { + a[i] = QRandomGenerator::global()->bounded( 4 ); + for ( int j = 0; j < i; j++ ) a[i] += sin( a[j] ); + a[0] += a[i]; + } + return( qRound( a[0] ) ); +} // slowFunction + + +/** + * \brief Быстрая функция + */ +int fastFunction() +{ + constexpr int size = 8 * 1024; + double a[size]; + for ( int i = 0; i < size; i++ ) + { + a[i] = QRandomGenerator::global()->bounded( 4 ); + for ( int j = 0; j < i; j++ ) a[i] += sin( a[j] ); + a[0] += a[i]; + } + return( qRound( a[0] ) ); +} + + /** * \brief Основная функция * \param argc Количество параметров командной строки @@ -67,6 +102,11 @@ int main( int argc, char** argv ) QObject::connect( &app, SIGNAL(aboutToQuit()), &p, SLOT(process())); QTimer::singleShot( 100, &app, SLOT(quit())); + #ifdef PROFILE + qCritical() << "Slow: " << slowFunction(); + qCritical() << "Fast: " << fastFunction(); + #endif + int arr[3]; qCritical() << arr[2]; return( QCoreApplication::exec() );