Compare commits
2 Commits
6cf49681fa
...
355daa934d
Author | SHA1 | Date | |
---|---|---|---|
355daa934d | |||
ac0421cbab |
@ -1,22 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* \file Основной файл проекта
|
||||||
|
*/
|
||||||
|
|
||||||
#include "processor.hpp"
|
#include "processor.hpp"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Перевод строки в целое число
|
||||||
|
* @param Строка
|
||||||
|
* @return Целое число
|
||||||
|
*/
|
||||||
int qStringToInt( const QString s )
|
int qStringToInt( const QString s )
|
||||||
{
|
{
|
||||||
return( s.toInt() );
|
return( s.toInt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Неиспользуемая функция для тестирования анализа покрытия кода
|
||||||
|
*/
|
||||||
int unused( int a )
|
int unused( int a )
|
||||||
{
|
{
|
||||||
return( 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 )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
QCoreApplication app( argc, argv );
|
QCoreApplication app( argc, argv );
|
||||||
@ -49,6 +102,11 @@ int main( int argc, char** argv )
|
|||||||
QObject::connect( &app, SIGNAL(aboutToQuit()), &p, SLOT(process()));
|
QObject::connect( &app, SIGNAL(aboutToQuit()), &p, SLOT(process()));
|
||||||
QTimer::singleShot( 100, &app, SLOT(quit()));
|
QTimer::singleShot( 100, &app, SLOT(quit()));
|
||||||
|
|
||||||
|
#ifdef PROFILE
|
||||||
|
qCritical() << "Slow: " << slowFunction();
|
||||||
|
qCritical() << "Fast: " << fastFunction();
|
||||||
|
#endif
|
||||||
|
|
||||||
int arr[3];
|
int arr[3];
|
||||||
qCritical() << arr[2];
|
qCritical() << arr[2];
|
||||||
return( QCoreApplication::exec() );
|
return( QCoreApplication::exec() );
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* \file Класс Processor
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef PROCESSOR_HPP_
|
#ifndef PROCESSOR_HPP_
|
||||||
#define PROCESSOR_HPP_
|
#define PROCESSOR_HPP_
|
||||||
|
|
||||||
@ -6,11 +10,17 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Класс Processor
|
||||||
|
*/
|
||||||
class Processor : public QObject
|
class Processor : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* \brief Слот, печатающий сообщение
|
||||||
|
*/
|
||||||
Q_SLOT void process() { qCritical() << "about to close"; }
|
Q_SLOT void process() { qCritical() << "about to close"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // ifndef PROCESSOR_HPP_
|
||||||
|
Loading…
Reference in New Issue
Block a user