usage examples are available in three files.
How to get the execution time of a line or a piece of code
1, usually use the Microtime function to get the microsecond time before and after the code and then compare the difference of two values, as follows
But this method is very limited, not a wide range of applications, and every time you need to write a lot of code, suitable for simple debugging. Please see the PHP manual for details.2, by using the Benchmark_timer class to get co
the beam cola
echo "Client Connection close\n";
Return
}
if ($RecvData ===false)
{
/*
Since we are using NONBLOBK mode
The situation here is that the external connection has no access to the information
*/
$NoRecvData =true;
Clear out last Errror
Socket_clear_error ($ServerSocket);
}
if ($NoRecvData $NoRemoteRecvData)
{
If external connections and VNC connections are not available to read,
Let the program sleep for 0.1 seconds to avoid long-term CPU resources
function:Linux provides a sleep function with different time accuracy. Some of these functions appear in the Linux high version, and some are non-thread safe. The following is a detailed description of each sleep function.Sleep#include From the parameter name of sleep, you can see that the function's sleep time unit is seconds. Since this sleep function may be interrupted by external signals, it has a return value that indicates the rest of the sleep time. If the time specified by the parameter
Benchmark_timer (); $timer->start (); $timer->setmarker (" Marker "); Usleep (1); $timer->setmarker (" marker "); Usleep (2); $timer->setmarker (" marker "); Usleep (3); Timer->stop (); $timer->display ();
There are two ways to print results: One is tabular output , $timer->display (), and the following figure Another is manual var_dump or Print_
original is this: "After the data is written, give a stop signal must be delayed after 10MS,24C02 need so long load data" This is 24C02 electrical characteristics.
In the Write function make a usleep (10000). Add: Our CPU is 6 cores 500M frequency, the computation processing ability is extremely strong. If the user layer to write a general delay program does not work, generally use 2 for, a for execution 10,000 times, on the PC there will be obvious
Article from: http://blog.sina.com.cn/s/blog_77051ec50101br8g.html
It is often necessary to do some delay processing in Linux shell scripts.So you often use sleep or usleep functions.Here's a look at the difference between sleep and usleep:
Sleep: Default in seconds.
Usleep: The default is in microseconds.
1s = 1000ms = 1000000us
Sleep can specify not only t
Analysis of Run loop in IOSAlthough Runloop is the key concept that the thread wants to close, but the runloop in cocoa is not used much, the View related blog post has not got to get started its "why". So shallow to learn a few days, a humble share of the shallow, as a note, write down its why. There is no wrong or wrong place, also hope to advise, not very grateful.Run Loop FAQWhen the thread finishes executing, it is destroyed. In order for the line Cheng Nen to run all the time, we can get a
Description: function name: SleepFunction: Execution hangs for a period of timeUsage: unsigned sleep (unsigned seconds);Using the top file in VC#include In the GCC compiler, the header file used differs depending on the GCC versionThe header files that the Linux system needs to add #include Note:In VC, the first English character in sleep is an uppercase "S"In standard C is sleep, do not capitalize. The following uses uppercase to illustrate, specifically what to see you with what compiler. Simp
() function to obtain the IServiceManager interface of SM;Call IServiceManager: addService () to save the object reference to the Binder Driver andRegister and manage ServiceManager so that other processes can find the corresponding service process through ServiceManager: getService
The above code is the same as that of serviceTestB service process.
B. Test the Service ProcessTestService. cpp:# Include # Include # Include # Include # Include # Include
Using namespace android;
Enum {CALCULATE_A
parameter.
function foo() { $o = $last = ''; do { $last = $o; usleep(10); $t = explode(' ', microtime()); $o = substr(base_convert(strtr($t[0].$t[1].$t[1], '.', ''), 10, 36), 0, 12); }while($o == $last); return $o;}Of course, this generation algorithm also has limitations. A 12-bit 36-digit number can have a maximum of pow (36, 12) states.
When the total volume exceeds pow (36, 12), repetition is inevitable.
The most easy to think o
This article mainly introduces the example of using multiple processes to simultaneously control file read/write in php. For more information, see
The code is as follows:
/**
* Write Data
* @ Param [string] $ path [file path]
* @ Param [string] $ mode [file opening mode]
* @ Param [string] $ data [data]
* @ Return [bool]
*/
Function writeData ($ path, $ mode, $ data ){
$ Fp = fopen ($ path, $ mode );
$ Retries = 0;
$ Max_retries = 100;
Do {
If ($ retries> 0 ){
. in addition, to determine the impact of result processing callback on performance comparison test results, you can use usleep to simulate the data processing logic (such as extraction, word segmentation, writing files or databases) that is more appropriate in reality ).
The callback functions used in performance testing are:
The code is as follows:
Function callback ($ data, $ delay ){
Preg_match_all ('/(. +)
Linux timer use Postedon2010-03-2017: 40feisky read (1073) Comments (0) edit favorite use timer is nothing more than to periodically execute a task, or it takes a specified time to execute a task. To achieve this goal, there are generally...
Linux timer usage
Posted on feisky reading (1073) Comments (0) edit favorites
The purpose of using a timer is nothing more than to periodically execute a task, or to execute a task at a specified time. To achieve this goal, there are generally two common ef
c). Synchronously sends, waits for a response, and receives 1 system messages after a timeout.Put code on it.#include #include"caf/all.hpp"#include"caf/io/all.hpp"#includestring>#include#include#includeusing namespacestd;using namespacecaf;behavior Fun (Event_based_actor*Self ) { return{[Self] (Const string STR,ConstActor buddy)string{aout (self)Endl; //Self->delayed_send (buddy,std::chrono::milliseconds), "I ' m lated"); //std::this_thread::sleep_for (Std::chrono::seconds (1)); //
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.