Questions tagged [microtime]

Anything related to programming languages functions (or other similar facilities) allowing the retrieval of the current time with a resolution in the microseconds range.

Anything related to programming languages functions (or other similar facilities) allowing the retrieval of the current time with a resolution in the microseconds (µs) range.

110 questions
1
vote
1 answer

Measure total site loading time in PHP

I'm looking for a way to measure each step of a (HTTP) web request in php similar to Firebug's timeline or http://tools.pingdom.com. I can use a timer to measure the web requests, but I am looking for some function in PHP that can give me the…
el Fo
  • 9
  • 4
1
vote
1 answer

Something goes wrong with PHP microtime parsing

Ok, I have this basics PHP logic made for measuring execution time in PHP, you can find it here. Everything was right, than I, instead of usual time execution range and format suddenly started to get incorrect results, like this: This page was…
Miloš Đakonović
  • 3,751
  • 5
  • 35
  • 55
0
votes
3 answers

How do I print the timing of a for loop before the output of the loop?

I don't know if the title is correct, anyway here is what I need: This is my code: $start = microtime(); $string = $_POST['string']; $matches = $SQL->prepare("SELECT * FROM `users` WHERE `name` LIKE…
Rym
  • 77
  • 1
  • 1
  • 7
0
votes
0 answers

LARAVEL_START inconsistent with multiple queue workers

In my Laravel app, I want to add the job execution time to each job's log. To do this I am subtracting LARAVEL_START from the current microtime() like this: $data['meta']['requestDuration'] = round((microtime(true) - LARAVEL_START) * 1000,…
0
votes
1 answer

Why is it that when the number of loops is increased, the execution is faster than when the number of loops is small?

Why is this code is faster the executiont time: $start_foreach = microtime(true); $counter = 1; foreach (range(1, 1000) as $number) { $counter++; } $end_foreach = microtime(true); $time_foreach = ($end_foreach - $start_foreach); echo…
0
votes
0 answers

microtime() or hrtime() for generating a unique number in a foreach loop

This has been asked before I think, but with key differences in the details... So I want to group an array of product sub-arrays by a specific grouping value found in some sub-arrays. The grouping value, however, isn't set for all of them, only for…
Faye D.
  • 833
  • 1
  • 3
  • 16
0
votes
1 answer

PHP (poor man's profiler) incorrect hrtime() difference

I'm implementing so-called poor man's profiling in PHP and doing it pretty straightforward way as you would expect: $start = hrtime(true); // API request is more than 1 second long $response = $this->getClient($cfg)->request($method, $url, ['query'…
Paul T. Rawkeen
  • 3,994
  • 3
  • 35
  • 51
0
votes
1 answer

Get latest from array of microtimes

I am looping through a list of files and grabbing their modified date, which is returned in microtime format: int(1633986072) int(1633971686) int(1634014866) int(1634000474) I can loop through these, but unsure which function is best to identify…
wharfdale
  • 1,148
  • 6
  • 23
  • 53
0
votes
2 answers

Jquery - How can i create a datetime in microformat

what ist the fastest way to create this date format with javascript/jquery? Wed, 03 Aug 2011 15:49:22 -0700 Thanks in advance! Peter
Peter
  • 11,413
  • 31
  • 100
  • 152
0
votes
2 answers

Angular 9 Issue: Unable to run the initial application

Can someone help me to resolve the following issue? I am following the https://v8.angular.io/guide/setup-local#prerequisites document to set up the initial application on my windows machine but facing an issue. OS: Windows 10, 64-bit Issue: npm…
rockey91
  • 142
  • 2
  • 10
0
votes
1 answer

Weird Issue on a benchmark in PHP

I have wrote this snippet to test the time that it takes to cast a string to integer and I tried this one here for fun but the result was so interesting.
Mahdi Bagheri
  • 23
  • 1
  • 9
0
votes
1 answer

How to get missing time to a microtime from another one, formatted (H:i:S) with PHP?

i am new to stackOverflow, i was wondering how could i get the missing time date to a microtime(true) starting from another microtime(true), and get it formatted like that (H:i:s). This is my code: $rewardCountdown = microtime(true) -…
HerryYT
  • 19
  • 8
0
votes
2 answers

Stop execution till the beginning of the next hour

I successfully find (i think) how many microseconds have to pass till the beginning of the next hour but usleep() function shows warning Number of microseconds must be greater than or equal to 0 $min = (integer)date('i'); $sec =…
Professor Chaos
  • 447
  • 5
  • 11
0
votes
1 answer

Convert microtime(true) to javascript date object

Can the value of PHP's microtime(true) be converted to a javascript date object, and the accuracy to be preserved ?
Alex
  • 66,732
  • 177
  • 439
  • 641
0
votes
0 answers

microtime showing 1.52214531583E+12

I am using round(microtime(true) * 1000); for generating current timestamp in 13 digits. But it is not returning me correct 13 digit values instead it return something like this: 1.52214531583E+12 which is not useful in my case. How can i convert…
Paritosh Mahale
  • 1,238
  • 2
  • 14
  • 42