CakePHP 2.1 Measuring Page Execution Time - time

How can I Measure the Page Execution Time in CakePHP 2.1?
In 1.3 it was rendered in the code when in debug mode.

You could use DebugKit Plugin to find out execution time.
Or you can edit index.php in app/ and add:
// top of file
$starTime = microtime(true);
// bottom of file
echo '<!-- Exec time: ', microtime(true) - $startTime, ' -->';
That time will be in microseconds so you could convert it to ms if you want, but DebugKit gives you a lot more information.

Note that the time returned from microtime is actually in seconds not microseconds according to the docs.

Related

Drupal 9 - custom module caching issue

Longtime D7 user, first time with D9. I am writing my first custom module and having a devil of a time. My routing calls a controller that simple does this:
\Drupal::service('page_cache_kill_switch')->trigger();
die("hello A - ". rand());
I can refresh the page over and over and get a new random number each
time. But, when I change the code to:
\Drupal::service('page_cache_kill_switch')->trigger();
die("hello B - ". rand());
I still get "hello A 34234234" for several minutes. Clearing the cache doesn't help, all I can do is wait, it's normally about two minutes. I am at my wits end.
I thought it maybe an issue with my docker instance. So I generated a simple HTML file but if I edit then reload that file changes are reflected immediately.
In my settings.local.php I have disabled the render cache, caching for migrations, Internal Page Cache, and Dynamic Page Cache.
In my mymod.routing.yml I have:
options:
_admin_route: TRUE
no_cache: TRUE
Any hint on what I am missing would be deeply appreciated.
thanks,
summer

Why do I see a big difference in loadtime between jMeter and user experience when browsing?

My problem is that I see the load time for a web page element on a test in jMeter # 200 miliseconds and when browsing, most of the time I get 3 or 4 seconds, in the condition where the size in bytes is # 331000.
I must mention that I cleared the cache and cookies for each iteration and I inserted also the constant timer between the steps.
The searching an id is the actual case described previously.
var pkg = JavaImporter(org.openqa.selenium);
var wait_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait);
var wait = new wait_ui.WebDriverWait(WDS.browser, 5000);
WDS.sampleResult.sampleStart()
var searchBox = WDS.browser.findElement(pkg.By.id("140:0;p"));
searchBox.click();
searchBox.sendKeys("1053606032");
searchBox.sendKeys(org.openqa.selenium.Keys.ENTER);
WDS.sampleResult.sampleEnd()
I expected to see the same load time results, but maybe an option would be if I wait until some elements on the search results page are visible. But I cannot bring an argument why is this difference. I had another case where the page loads in 10 seconds in Chrome and in jMeter Test Results 300 miliseconds.
Please try with wait until for a specific element which loads as close as the page load.
Below is another try for the same. Use the below code and check if this helps:-
WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter-plugins.org')
//(JavascriptExecutor)WDS.browser.executeScript("return document.readyState").toString().equals("complete")
WDS.browser.executeScript("return document.readyState").toString().equals("complete")
WDS.sampleResult.sampleEnd()
For me without execute script page loads in 3 sec and with executeScript it loads in 7 sec..while in browser that loads in around 7.57sec..
Hope this helps.

High Precision Log Time for Chef Logs

I am starting to work with chefserver. I want to get some calculation from the logs of chefserver. However, the time stamp is displayed without milliseconds. In order to get more precise calculation I want the logs of the recipes to have milliseconds.
The logs are in the following format:
[2017-08-29T18:44:22+00:00] INFO: bash[dummyResource] ran successfully
Thanks in advance
You can change the formatter in your client.rb (or in cookbook library code but then it would only affect things after that code runs):
Chef::Log.logger.formatter = whatever
https://github.com/chef/mixlib-log/blob/master/lib/mixlib/log/formatter.rb shows the default formatter, you can subclass and tweak as you desire.

redirect function is not working when it takes time in processing

I am using form. I am unable to redirect after completion of process. It is working proper when I have less amount of data for processing but when data is high, it is taking time 10 to 15 minutes and here it is unable to redirect on another location.
following this
view.php
doing my work
after completing functionality.
$controller->redirect_function($path);
controller.php
function redirect_function($path){
redirect($path);
}
Please help
Your script must be dying before completion because of the timeout value set in your php.ini.
You can use set-time-limit function to increase the maximum time a script can run.

Laravel Illuminate\Contracts\Http\Kernel response in index.php takes over a second to execute

I've been running some benchmark tests to find out why my application was running tremendously slow. Our application runs on an ec2 m3 instance with a mysql database on RDS. At first I thought it had something to do with RDS or a bad configuration. But as I started putting time checks in the code I came to the conclusion that as optimized as my code was - apparently the laravel kernal itself was taking a long time to execute.
In one of my main controllers the average execution time for all the code within the controller was around 200 - 175ms.
However the page would load taking an excruciating 1.3 seconds! There was definitely nothing wrong in the code for the controller so I figured something else must be causing the issue so I benchmarked the base code in the index.php file in the public directory of Laravel application and found that creating a Illuminate\Contracts\Http\Kernel object and getting/sending the response alone took 1120ms!
<?php
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
// FROM HERE ->
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
//<--to here takes 1120 ms of which 200 ms is my code in the controller
$kernel->terminate($request, $response);
I'm assuming this is a framework issue but how can I overcome this - a one second average response time is unacceptable here.
Probably there might be thousands reasons for this. What you should do is profile your code to verify what takes so long.
But the first thing I would consider is database connection and queries that are executed. If you execute for example 10 queries and each takes 100ms, queries execution will take 1s, so you might get total 1.3 seconds and it's nothing strange.
So you should verify your code what exactly is happening, verify execution time for simple controller action (that only returns some string for example), verify what providers are loaded etc because each such thing can affect general performance.

Resources