Commit e98d1c87 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Add benchmark for filter runtime

parent 31b2b520
......@@ -183,6 +183,7 @@ endif( )
if( ITA_SIMULATION_SCHEDULER_BENCHMARKS )
add_subdirectory( "benchmarks/basic_bench_with_profiler" )
add_subdirectory( "benchmarks/filter_evaluation_time" )
if( ITA_SIMULATION_SCHEDULER_RAVEN_MODULE )
endif( )
......
cmake_minimum_required( VERSION 2.8 )
project( ITASimulationScheduler_filter_evaluation_time )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITASimulationScheduler REQUIRED FIND_DEPENDENCIES )
set( ProjectSources "main.cpp" )
add_executable( ITASimulationScheduler_filter_evaluation_time ${ProjectSources} )
target_link_libraries( ITASimulationScheduler_filter_evaluation_time ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITASimulationScheduler_filter_evaluation_time )
vista_create_default_info_file( ITASimulationScheduler_filter_evaluation_time )
set_property( TARGET ITASimulationScheduler_filter_evaluation_time PROPERTY FOLDER "ITASimulationScheduler/Benchmarks" )
#include <array>
#include <ITA/SimulationScheduler/AudibilityFilter/rate_filter.h>
#include <ITA/SimulationScheduler/AudibilityFilter/perceptive_rotation_filter.h>
#include <ITA/SimulationScheduler/AudibilityFilter/distance_filter.h>
#include <ITA/SimulationScheduler/AudibilityFilter/translation_filter.h>
#include <ITA/SimulationScheduler/AudibilityFilter/zone_filter.h>
#include <ITA/SimulationScheduler/AudibilityFilter/rotation_filter.h>
#include <ITA/SimulationScheduler/update_scene.h>
#include <ITA/SimulationScheduler/3d_object.h>
#include <ITAStopWatch.h>
#include <iostream>
#include <filesystem>
using namespace ITA::SimulationScheduler;
using namespace AudibilityFilter;
int main ( )
{
const int runs = 500000;
CUpdateScene prevUpdate ( 0 );
CUpdateScene newUpdate ( 0 );
C3DObject source ( VistaVector3D ( 0, 0, 0 ), VistaQuaternion ( 0, 0, 0, 1 ), C3DObject::Type::source, 0 );
C3DObject receiver ( VistaVector3D ( 0, 0, 0 ), VistaQuaternion ( 0, 0, 0, 1 ), C3DObject::Type::receiver, 0 );
prevUpdate.SetSourceReceiverPair ( std::make_unique<C3DObject> ( source ), std::make_unique<C3DObject> ( receiver ) );
newUpdate.SetSourceReceiverPair ( std::make_unique<C3DObject> ( source ), std::make_unique<C3DObject> ( receiver ) );
CRateFilter::RateFilterConfig rateFilterConfig;
CRateFilter rateFilter ( rateFilterConfig );
CPerceptiveRotationFilter::PerceptiveRotationFilterConfig perceptiveRotationFilterConfig;
CPerceptiveRotationFilter perceptiveRotationFilter ( perceptiveRotationFilterConfig );
CDistanceFilter::DistanceFilterConfig distanceFilterConfig;
CDistanceFilter distanceFilter ( distanceFilterConfig );
CRotationFilter::RotationFilterConfig rotationFilterConfig;
rotationFilterConfig.eMode = CRotationFilter::RotationModes::absolute;
CRotationFilter absoluteRotationFilter ( rotationFilterConfig );
rotationFilterConfig.eMode = CRotationFilter::RotationModes::relative;
CRotationFilter relativeRotationFilter ( rotationFilterConfig );
CTranslationFilter::TranslationFilterConfig translationFilterConfig;
translationFilterConfig.eMode = CTranslationFilter::TranslationModes::absolute;
CTranslationFilter absoluteTranslationFilter ( translationFilterConfig );
translationFilterConfig.eMode = CTranslationFilter::TranslationModes::relative;
CTranslationFilter relativeTranslationFilter ( translationFilterConfig );
CZoneFilter::ZoneFilterConfig zoneFilterConfig;
CZoneFilter zeroZoneFilter ( zoneFilterConfig );
zoneFilterConfig.vpZones.emplace_back ( VistaVector3D ( 0, 0, 0 ), VistaVector3D ( 1, 1, 1 ) );
CZoneFilter oneZoneFilter ( zoneFilterConfig );
zoneFilterConfig.vpZones.emplace_back ( VistaVector3D ( 0, 0, 0 ), VistaVector3D ( 1, 1, 1 ) );
CZoneFilter twoZoneFilter ( zoneFilterConfig );
zoneFilterConfig.vpZones.emplace_back ( VistaVector3D ( 0, 0, 0 ), VistaVector3D ( 1, 1, 1 ) );
CZoneFilter threeZoneFilter ( zoneFilterConfig );
ITAStopWatch rateFilterSW;
ITAStopWatch perceptiveRotationFilterSW;
ITAStopWatch distanceFilterSW;
ITAStopWatch absoluteRotationFilterSW;
ITAStopWatch relativeRotationFilterSW;
ITAStopWatch absoluteTranslationFilterSW;
ITAStopWatch relativeTranslationFilterSW;
ITAStopWatch zeroZoneFilterSW;
ITAStopWatch oneZoneFilterSW;
ITAStopWatch twoZoneFilterSW;
ITAStopWatch threeZoneFilterSW;
std::vector<std::pair<IAudibilityFilter*, ITAStopWatch*>> filterVector;
filterVector.emplace_back ( &rateFilter, &rateFilterSW );
filterVector.emplace_back ( &perceptiveRotationFilter, &perceptiveRotationFilterSW );
filterVector.emplace_back ( &distanceFilter, &distanceFilterSW );
filterVector.emplace_back ( &absoluteRotationFilter, &absoluteRotationFilterSW );
filterVector.emplace_back ( &relativeRotationFilter, &relativeRotationFilterSW );
filterVector.emplace_back ( &absoluteTranslationFilter, &absoluteTranslationFilterSW );
filterVector.emplace_back ( &relativeTranslationFilter, &relativeTranslationFilterSW );
filterVector.emplace_back ( &zeroZoneFilter, &zeroZoneFilterSW );
filterVector.emplace_back ( &oneZoneFilter, &oneZoneFilterSW );
filterVector.emplace_back ( &twoZoneFilter, &twoZoneFilterSW );
filterVector.emplace_back ( &threeZoneFilter, &threeZoneFilterSW );
for ( auto& filter : filterVector )
{
for ( int i = 0; i < runs; ++i )
{
filter.second->start ( );
auto result = filter.first->ChangeIsAudible ( prevUpdate, newUpdate );
filter.second->stop ( );
}
}
std::stringstream ss;
ss << "Rate Filter: " << rateFilterSW.ToString ( ) << "\n";
ss << "Perceptive Rotation: " << perceptiveRotationFilterSW.ToString ( ) << "\n";
ss << "Distance Filter: " << distanceFilterSW.ToString ( ) << "\n";
ss << "Absolute RotationFilter: " << absoluteRotationFilterSW.ToString ( ) << "\n";
ss << "RelativeRotation Filter: " << relativeRotationFilterSW.ToString ( ) << "\n";
ss << "Absolute Translation Filter: " << absoluteTranslationFilterSW.ToString ( ) << "\n";
ss << "Relative Translation Filter: " << relativeTranslationFilterSW.ToString ( ) << "\n";
ss << "Zero Zone Filter: " << zeroZoneFilterSW.ToString ( ) << "\n";
ss << "One Zone Filter: " << oneZoneFilterSW.ToString ( ) << "\n";
ss << "Two Zone Filter: " << twoZoneFilterSW.ToString ( ) << "\n";
ss << "Three Zone Filter: " << threeZoneFilterSW.ToString ( );
std::cout << ss.str ( );
std::ofstream myfile;
myfile.open ( "filterEvalResults.txt" );
myfile << ss.str ( );
myfile.close ( );
return 0;
}
\ No newline at end of file
%% clear
clc
clear
%% load stuff
load('RWTHColorsSorted.mat');
files = dir('filterEvalResults*.txt');
%% start
content = fileread(files(1).name);
lines = splitlines(content);
lines = strrep(lines,': avg=',', ');
lines = strrep(lines,'stddev=','');
lines = strrep(lines,'min=','');
lines = strrep(lines,'max=','');
lines = strrep(lines,'cycles=','');
lines = strrep(lines,'ns,','e-9,');
lines = strrep(lines,'us,','e-6,');
lines = strrep(lines,'ms,','e-3,');
lines = strrep(lines,'s','');
data = split(lines,', ');
tab = cell2table(data,...
'VariableNames',{'name','mean','stddev','min','max','cycles'});
for i = 2:width(tab)
if iscell(tab.(i))
tab.(i) = str2double(tab.(i));
end
end
%% plot
yAxisDimension = 1e-6;
h = figure;
colororder(RWTHColorsSorted);
h.Position = [0, 0, 1440, 1080] * .9;
b = bar(tab.mean / yAxisDimension);
xticklabels(tab.name)
xtickangle(45)
hold on;
xtips = b.XEndPoints;
ytips = b.YEndPoints;
lab = string(num2str(tab.mean,'%10.2e'));
errorbar(xtips,reshape(tab.mean / yAxisDimension,1,[]),reshape(tab.stddev / yAxisDimension,1,[]),'k','linestyle','none','linewidth',1)
tmpY = ylim;
text(xtips(ytips > 0),repmat(tmpY(2),size(xtips)),lab,'HorizontalAlignment','center',...
'VerticalAlignment','middle')
ylim(ylim * 1.1);
yticks = yticks / yAxisDimension;
ylabel('Filter Evaluation Runtime in us')
title('Filter Evaluation Runtime Comparison');
%% save fig
savefig(h,'RuntimesNoProfiler.fig','compact');
exportgraphics(h,'RuntimesNoProfiler.png');
exportgraphics(h,'RuntimesNoProfiler.pdf');
close all;
%% start
content = fileread(files(2).name);
lines = splitlines(content);
lines = strrep(lines,': avg=',', ');
lines = strrep(lines,'stddev=','');
lines = strrep(lines,'min=','');
lines = strrep(lines,'max=','');
lines = strrep(lines,'cycles=','');
lines = strrep(lines,'ns,','e-9,');
lines = strrep(lines,'us,','e-6,');
lines = strrep(lines,'ms,','e-3,');
lines = strrep(lines,'s','');
data = split(lines,', ');
tab = cell2table(data,...
'VariableNames',{'name','mean','stddev','min','max','cycles'});
for i = 2:width(tab)
if iscell(tab.(i))
tab.(i) = str2double(tab.(i));
end
end
%% plot
yAxisDimension = 1e-6;
h = figure;
colororder(RWTHColorsSorted);
h.Position = [0, 0, 1440, 1080] * .9;
b = bar(tab.mean / yAxisDimension);
xticklabels(tab.name)
xtickangle(45)
hold on;
xtips = b.XEndPoints;
ytips = b.YEndPoints;
lab = string(num2str(tab.mean,'%10.2e'));
errorbar(xtips,reshape(tab.mean / yAxisDimension,1,[]),reshape(tab.stddev / yAxisDimension,1,[]),'k','linestyle','none','linewidth',1)
tmpY = ylim;
text(xtips(ytips > 0),repmat(tmpY(2),size(xtips)),lab,'HorizontalAlignment','center',...
'VerticalAlignment','middle')
ylim(ylim * 1.1);
yticks = yticks / yAxisDimension;
ylabel('Filter Evaluation Runtime in us')
title('Filter Evaluation Runtime Comparison');
%% save fig
savefig(h,'RuntimesWithProfiler.fig','compact');
exportgraphics(h,'RuntimesWithProfiler.png');
exportgraphics(h,'RuntimesWithProfiler.pdf');
close all;
%% start
content = fileread(files(3).name);
lines = splitlines(content);
lines = strrep(lines,': avg=',', ');
lines = strrep(lines,'stddev=','');
lines = strrep(lines,'min=','');
lines = strrep(lines,'max=','');
lines = strrep(lines,'cycles=','');
lines = strrep(lines,'ns,','e-9,');
lines = strrep(lines,'us,','e-6,');
lines = strrep(lines,'ms,','e-3,');
lines = strrep(lines,'s','');
data = split(lines,', ');
tab = cell2table(data,...
'VariableNames',{'name','mean','stddev','min','max','cycles'});
for i = 2:width(tab)
if iscell(tab.(i))
tab.(i) = str2double(tab.(i));
end
end
%% plot
yAxisDimension = 1e-6;
h = figure;
colororder(RWTHColorsSorted);
h.Position = [0, 0, 1440, 1080] * .9;
b = bar(tab.mean / yAxisDimension);
xticklabels(tab.name)
xtickangle(45)
hold on;
xtips = b.XEndPoints;
ytips = b.YEndPoints;
lab = string(num2str(tab.mean,'%10.2e'));
errorbar(xtips,reshape(tab.mean / yAxisDimension,1,[]),reshape(tab.stddev / yAxisDimension,1,[]),'k','linestyle','none','linewidth',1)
tmpY = ylim;
text(xtips(ytips > 0),repmat(tmpY(2),size(xtips)),lab,'HorizontalAlignment','center',...
'VerticalAlignment','middle')
ylim(ylim * 1.1);
yticks = yticks / yAxisDimension;
ylabel('Filter Evaluation Runtime in us')
title('Filter Evaluation Runtime Comparison');
%% save fig
savefig(h,'RuntimesWithProfilerOpt.fig','compact');
exportgraphics(h,'RuntimesWithProfilerOpt.png');
exportgraphics(h,'RuntimesWithProfilerOpt.pdf');
close all;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment