Skip to content
Snippets Groups Projects
Commit 0f50cf47 authored by Soeren Peters's avatar Soeren Peters
Browse files

- add timer class

parent fcddedc4
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@
#include "Serialization/GeometryMemento.h"
#include <GridGenerator/geometries/Triangle/Serialization/TriangleMemento.h>
#include "Timer/Timer.h"
TriangularMesh* TriangularMesh::make(const std::string& fileName)
......@@ -58,14 +59,17 @@ void TriangularMesh::findNeighbors()
*logging::out << logging::Logger::INTERMEDIATE << "start finding neighbors ...\n";
const clock_t begin = clock();
Timer t = Timer::begin();
TriangleNeighborFinder finder(triangles, size);
finder.fillWithNeighborAngles(this);
const clock_t end = clock();
t.end();
const real time = real(end - begin) / CLOCKS_PER_SEC;
*logging::out << logging::Logger::INTERMEDIATE << "time finding neighbors: " << time << "s\n";
*logging::out << logging::Logger::INTERMEDIATE << "time finding neighbors: " << time << "s\n";
*logging::out << logging::Logger::INTERMEDIATE << "time finding neighbors: " << t.getTimeInSeconds() << "s\n";
}
void TriangularMesh::setTriangles(std::vector<Triangle> triangles)
......
#include "Timer.h"
#include <ctime>
Timer::Timer()
{
}
Timer Timer::begin()
{
Timer t;
t.beginInClocks = clock();
return t;
}
void Timer::end()
{
const clock_t endInClocks = clock();
timeInClocks = endInClocks - beginInClocks;
}
real Timer::getTimeInSeconds() const
{
return real(timeInClocks) / CLOCKS_PER_SEC;
}
\ No newline at end of file
#ifndef TIMER_H
#define TIMER_H
#include <VirtualFluidsDefinitions.h>
#include <DataTypes.h>
class VF_PUBLIC Timer
{
public:
Timer();
static Timer begin();
void end();
real getTimeInSeconds() const;
private:
long beginInClocks;
long timeInClocks;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment