Jump to content
UBot Underground

JS Timer failing


Recommended Posts

I'm trying to time the execution of my bot and display a message on completion of how long it ran. Here are the code snippets I'm using...

 

1. At the start of my bot goes:

 

var start = new Date().getTime();

 

2. At the end of the bot goes:

 

var elapsed = (new Date().getTime() - start) / 60000;

alert('Total elapsed time: ' + Math.round(elapsed*100)/100 + ' minutes.');

 

It works perfectly... UNTIL the bot navigates to any page other than the originating one. Then it loses the value stored in "start" completely.

 

Does anyone either know why this is happening, or a way to achieve the result I'm looking for?

 

Thanks!

 

Jonathan

Link to post
Share on other sites

You should store the start time in a variable, then you won't have to worry about losing it in your js function.

 

yeah I tried doing that, can't get it to work either...

 

Here is what I've done:

node 1 -

set #start

eval "var start = new Date().getTime();"

node 2 - 

set #elapsed

eval "var elapsed = (new Date().getTime() - {1}) / 60000;"
{1} = #start

node 3 - 

set #final_time

eval "{1} - {2}"
{1} = #elapsed
{2} = #start

node 4 - 

set #timer_msg

alert('Total elapsed time: ' + Math.round({1}*100)/100 + ' minutes.');
{1} = #final_time

node 5 - 

run javascript
alert('{1}');
{1} = #timer_msg

 

Hopefully this makes sense... am I even remotely on the right track here?

 

Jonathan

Link to post
Share on other sites

That "appears" good to me. You should use the UI Monitor to report those variables as they resolve. You can institute delays between nodes to give the stat monitors time to update. It may help you track down the issue.

 

Sorry I can't be more help, I'm not much of a js whiz. I can read what you wrote, but I am not sure how to improve it, or what specific details might be incorrect.

Link to post
Share on other sites
  • 1 month later...

*bump*

 

I was never able to solve this... anyone else have any ideas? I think what's happening is that as soon as i nav to any other page, I lose all the previously created javascript activity, and even though the values are being stored in variables, JS seems unable to access them at the end of the script.

 

Anyone else know how to time activity in UBot across multiple page loads?

 

Jonathan

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...