Node Execution Start/Stop Timestamp

Hi there,

I'm a new boy to the world of Knime so excuse me if I ask questions which, to all of you, are very simple...I'll get there :)

I would like to track the start and end time for each node in a workflow, in particular I'm interested in the start/end times for nodes which use JDBC to access a database.

Is there an in-built configuration/node for this type of thing which will also output the Start/End times for a given node to a log file?

Any help or advice on this would be very much appreciated.

Regards

Matt :)

Hello Matt,

 

I would use a Java Edit Variable (simple) node on the node that should start the timer, and configure it as such:

[Method Body]return (double)System.currentTimeMillis();

[Define Variable]timerStartedAt

[Return type]Double

 

Your variable timerStartedAt is available throughout your whole workflow, so you can just connect the variable port of the node that should stop the timer to another Java Edit Variable (simple), and configure it as such:

[Method Body]return ((double)System.currentTimeMillis() - $${DtimerStartedAt}$$) / 1000;

[Define Variable]timeSpentInSeconds

[Return type]Double

 

Your variable timeSpentInSeconds contains the time it took your process to execute.

 

There are more than one way to skin a cat in Knime and this may not be the most elegant/efficient.

 

HTH,

Fred

Hi Fred,

Thanks for your reply.  I've setup the two variables as you describe, but (sorry :|) I have no idea how to link them into my flow.  I only have two nodes in the flow node #1 is a file reader and node #2 is a sort (I'm testing this and will move on to JDBC stuff when I've mastered this timer thing).  Where do I link in the variables so that they do as you are suggesting? And how can I output the values to a LOG file?

Sorry if this is simple stuff to you :|

Regards

Matt

Hey Matt,

 

No worries, we have all been at the stage you're at!

 

Your workflow would need at least four nodes, the first Java Edit Variable (simple) node would connect the variable outport (the red dot at the top right-hand corner of your node) of node #1 to the variable inport (the red dot at the top left-hand corner of your node) of node #2. The other java node would link nodes #3 and #4 in the same manner.

 

You have many ways to write this value to a log file. You could use a Variable To TableColumn node and a CSV Writer node, specifying "\t" in the Data Separator section of the Advanced tab, for instance.

 

Don't hestitate to post your questions,

Fred

Hi Fred, 

I am trying to do the exactly the same thing here, and I have two nodes in my work flow. One node is to import data from a certain source and another node to upload the data in to a database. Is this corret? Why should there be at least four nodes in the workflow?

Cheers,

Jingting