Compare commits

..

2 Commits

2 changed files with 69 additions and 1 deletions

View File

@ -1,22 +1,75 @@
/**
* \file Основной файл проекта
*/
#include "processor.hpp"
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QRandomGenerator>
#include <QTimer>
/**
* @brief Перевод строки в целое число
* @param Строка
* @return Целое число
*/
int qStringToInt( const QString s )
{
return( s.toInt() );
}
/**
* \brief Неиспользуемая функция для тестирования анализа покрытия кода
*/
int unused( int a )
{
return( 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 Количество параметров командной строки
* \param argv Массив параметров
* \return Результат выполнения QApplication::exec()
*/
int main( int argc, char** argv )
{
QCoreApplication app( argc, argv );
@ -49,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() );

View File

@ -1,3 +1,7 @@
/**
* \file Класс Processor
*/
#ifndef PROCESSOR_HPP_
#define PROCESSOR_HPP_
@ -6,11 +10,17 @@
#include <QObject>
#include <QDebug>
/**
* \brief Класс Processor
*/
class Processor : public QObject
{
Q_OBJECT
public:
/**
* \brief Слот, печатающий сообщение
*/
Q_SLOT void process() { qCritical() << "about to close"; }
};
#endif
#endif // ifndef PROCESSOR_HPP_