Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, windows and java based applications. Get your 30 day free trial.
Discuss your Sahi Pro usage patterns, best practices, problems and solutions. Help others solve their problems and seek help from the community when needed. If you need specific support on your application, please email support @ sahipro.com
Discuss your Sahi Pro usage patterns, best practices, problems and solutions. Help others solve their problems and seek help from the community when needed. If you need specific support on your application, please email support @ sahipro.com
It is possible to display with Sahi the run time for a specific script
mihaimacarie
Members
Hello there,
It is possible to display with Sahi the run time for a specific script ? I mean ... to define a timer.
e.g. (PHP code)
$start_time = microtime(true);
// source code ...
// source code ...
$end_time = microtime(true);
$run_time = $end_time - $start_time;
echo "Run Time = ".$run_time;
Thanks,
Mihai
It is possible to display with Sahi the run time for a specific script ? I mean ... to define a timer.
e.g. (PHP code)
$start_time = microtime(true);
// source code ...
// source code ...
$end_time = microtime(true);
$run_time = $end_time - $start_time;
echo "Run Time = ".$run_time;
Thanks,
Mihai
Comments
Don't know if there is some way to get script execution time. Here is what I do:
And the idea is to call the function(within log statement) at the very begining of the script and after the last step of the script. The difference of time will give you the time of execution.
You can also add seconds to it. Same logic can be extended further to do time calculations for finding difference between the two times.
Regards,
Pankaj.
Pankaj, can you explain to me, if is possible, how I integrate currentTime() javascript function into a Sahi script? I don't know how to call the function into a _log() statement.
Narayan, your code is working fine, thank you again for your answer.
Regards,
Mihai
Sure. Use this function instead: And this is how i use it: I use an older version of sahi (without rhino) and it works fine there. Let me know if this function has some problems with the newer version.
Regards,
Pankaj.
When I try to run the script using currentTime() function, Sahi Controller returns the following error:
_log("==== Script Execution Started At " + currentTime() + " ====", "success"); ReferenceError: currentTime is not defined
...
- but there is not a big problem, I modified Narayan's function for my environment and everything working fine. Here is the function:
Function Call:
Thanks a lot for the support
Regards,
Mihai
Below is a working demo code that worked on sahi rhino version: It took 20 seconds to execute on my machine.
Hope this helps you
Regards,
Pankaj.
The last function display correctly the time.
Thank you,
Mihai
Thought of sharing a function ( timeDifference() ) that I just jotted down to calculate the difference of two times to calculate the execution time of a script. this we can use in conjunction with the above mentioned function currentTime().
Will explain with an example: You can use/modify it as per your requirements
Regards,
Pankaj.
The last function posted, was tested and is working fine.
Regards,
Mihai
I tried the above fn but getting this error
ReferenceError: "_log" is not defined.
can some one please explain , what am I missing here ?
Regards,
Abdul