summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2014-02-11 23:46:05 +0000
committerComment <tim@gray.(none)>2014-02-11 23:46:05 +0000
commitd537803422b5832d1b4a2f3fde6fae8704448638 (patch)
tree4b4b1f4d695d90cf4eea5257fb8c7edf8865d578 /rotord
parent98deb07854e39eee7861278b3a319b3a0edfb3c8 (diff)
fixed analytics
Diffstat (limited to 'rotord')
-rw-r--r--rotord/src/graph.cpp12
-rw-r--r--rotord/src/rotor.cpp32
-rw-r--r--rotord/src/rotor.h91
3 files changed, 63 insertions, 72 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp
index c356916..566d7b0 100644
--- a/rotord/src/graph.cpp
+++ b/rotord/src/graph.cpp
@@ -250,20 +250,22 @@ bool Graph::video_render(const string &output_filename,const double framerate,in
double mtime = ((_end.tv_sec-_start.tv_sec) + (_end.tv_usec-_start.tv_usec)/1000000.0);
logger.information("Video_output: rendered "+namestub+suffix+": in "+toString(mtime)+" seconds");
- logger.information("compression codec took "+toString(mtime-video_output->time_taken)+" seconds");
-
+
for (auto n:nodes) {
- logger.information(n.second->type+" node '"+n.first+"' took "+toString(n.second->get_time_used())+" seconds");
+ if (dynamic_cast<Image_node*>(n.second)){
+ logger.information(n.second->type+" node '"+n.first+"' took "+toString(n.second->get_time_used())+" seconds");
+ }
+ mtime-=n.second->get_time_used();
}
+ logger.information("compression codec took "+toString(mtime)+" seconds");
+
if (usingaudio) {
audioloader.cleanup();
delete[] audioframe;
delete[] audio;
}
-
-
return true;
}
}
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index b31e2ce..cbfad2b 100644
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -86,18 +86,6 @@ Node_factory::Node_factory(){
add_type("slider",new Slider(),category["UI"]);
}
-double Signal_input::get_time_used(){
- if (connection){
- return ((Signal_node*)connection)->get_time_used();
- }
- return 0.0;
-}
-double Signal_input::get_time_taken(){
- if (connection){
- return ((Signal_node*)connection)->time_taken;
- }
- return 0.0;
-}
bool Signal_input::connect(Node* source) {
connection=dynamic_cast<Signal_node*>(source);
if (connection) return true;
@@ -109,18 +97,6 @@ double Signal_input::get(const Time_spec& time){ //gets input and updates variab
}
else return 0.0;
}
-double Image_input::get_time_used(){
- if (connection){
- return ((Image_node*)connection)->get_time_used();
- }
- return 0.0;
-}
-double Image_input::get_time_taken(){
- if (connection){
- return ((Image_node*)connection)->time_taken;
- }
- return 0.0;
-}
bool Image_input::connect(Node* source) {
connection=dynamic_cast<Image_node*>(source);
if (connection) return true;
@@ -128,7 +104,13 @@ bool Image_input::connect(Node* source) {
}
Image* Image_input::get(const Frame_spec& time){ //gets input and updates variable
if (connection){
- return (((Image_node*)connection)->get_image_output(time));
+ struct timeval begin_time;
+ gettimeofday(&begin_time, NULL);
+ Image* im=(((Image_node*)connection)->get_image_output(time));
+ struct timeval end_time;
+ gettimeofday(&end_time, NULL);
+ time_taken=((end_time.tv_sec-begin_time.tv_sec) + ((end_time.tv_usec-begin_time.tv_usec)/1000000.0));
+ return im;
}
else return nullptr;
}
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 9c484c9..05cff46 100644
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -234,8 +234,6 @@ namespace Rotor {
Node* connection;
string description;
string title;
- virtual double get_time_used()=0;
- virtual double get_time_taken()=0;
};
class Image_input: public Input{
public:
@@ -245,8 +243,10 @@ namespace Rotor {
connect(_connect);
};
Image* get(const Frame_spec& time);
- double get_time_used();
- double get_time_taken();
+ double get_time_taken(){return time_taken;};
+ void reset_time_taken(){time_taken=0.0;};
+ private:
+ double time_taken;
};
class Signal_input: public Input{
public:
@@ -256,8 +256,6 @@ namespace Rotor {
connect(_connect);
};
double get(const Time_spec& time);
- double get_time_used();
- double get_time_taken();
};
class Parameter: public Signal_input{
public:
@@ -409,49 +407,58 @@ namespace Rotor {
}
}
}
+ void set_parameter(const std::string &key,const std::string &value){
+ if (parameters.find(key)!=parameters.end()) parameters[key]->value=toFloat(value);
+ };
void update(const Time_spec &time){
gettimeofday(&frame_time, NULL);
for (auto p: parameters){
p.second->get(time);
}
}
- void set_parameter(const std::string &key,const std::string &value){
- if (parameters.find(key)!=parameters.end()) parameters[key]->value=toFloat(value);
- };
void reset(){
- time_taken=0.0;
+ time_used=time_taken=0.0;
init();
}
- void time_frame(){
- struct timeval end_time;
- gettimeofday(&end_time, NULL);
- time_taken+=((end_time.tv_sec-frame_time.tv_sec) + (end_time.tv_usec-frame_time.tv_usec)/1000000.0);
+ double get_time_used(){
+ return time_used;
}
- virtual double get_time_used()=0;
- double time_taken;
+ double time_taken,time_used;
protected:
- struct timeval frame_time;
+ struct timeval frame_time;
};
class Signal_node: public Node{
- public:
- virtual ~Signal_node(){};
- const double get_output(const Time_spec &time) {
- update(time);
- double o=output(time);
- time_frame();
- return o;
- };
- const double get_time_for_value(const double &value) {
- return 0.0;
+ public:
+ virtual ~Signal_node(){};
+ const double get_output(const Time_spec &time) {
+ update(time);
+ return output(time);
+ };
+ const double get_time_for_value(const double &value) {
+ return 0.0;
+ };
+ virtual const double output(const Time_spec &time) { return 0.0; };
};
- virtual const double output(const Time_spec &time) { return 0.0; };
- double get_time_used(){
- double t=time_taken;
- for (auto i:inputs) t-=i->get_time_taken();
- for (auto p:parameters) t-=p.second->get_time_taken();
- return t;
- }
- };
+ //
+ // There is a conceptual problem with the timing
+ // if we connect more than one node to an output, need it to be counted only once
+ // if more than 1 input of a node is connected to the same output, how do we calculate this?
+ // do we need to reference count?
+ //
+ // image node inits -> start timer
+ // call other nodes
+ // end timer
+ //
+ // each node knows how long it had the timer
+ // and what nodes it called
+ // calls change SO
+ // the INPUTS need to track time SEPERATELY from the node itself
+ // YES!
+ // then each input knows how long it should seperately time
+ // is there a case for a timer object?
+ //
+ // class timer: start, stop,
+ //
class Image_node: public Node{
public:
virtual ~Image_node(){
@@ -462,6 +469,7 @@ namespace Rotor {
image_inputs.push_back(new Image_input(_desc,_title,_connect));
};
Image *get_image_output(const Frame_spec &frame) {
+ for (auto i:image_inputs) i->reset_time_taken();
update((Time_spec)frame);
image.setup(frame.w,frame.h);
Image *i=output(frame);
@@ -474,14 +482,13 @@ namespace Rotor {
image.clear();
}
Image image;
- double get_time_used(){
- double t=time_taken;
- for (auto i:inputs) t-=i->get_time_taken();
- for (auto p:parameters) t-=p.second->get_time_taken();
- for (auto i:image_inputs) t-=i->get_time_taken();
- return t;
+ void time_frame(){
+ struct timeval end_time;
+ gettimeofday(&end_time, NULL);
+ time_taken=((end_time.tv_sec-frame_time.tv_sec) + ((end_time.tv_usec-frame_time.tv_usec)/1000000.0));
+ for (auto i:image_inputs) time_taken-=i->get_time_taken();
+ time_used+=time_taken;
}
-
private:
double image_time; //? could be used to detect image reuse?