পিএইচপি সংস্করণ 7+ এ, গেট্রুসেজ ফাংশন ব্যবহার করা যেতে পারে। নীচে একটি নমুনা কোড প্রদর্শন −
উদাহরণ
//beginning of the script
$exec_start = getrusage();
//other code functionalities
//end of the script
function rutime($ru, $rus, $index) {
return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000))
- ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000));
}
$ru = getrusage();
echo "The process used " . rutime($ru, $exec_start, "utime") .
" ms for the computations\n";
echo "Spent " . rutime($ru, $exec_start, "stime") .
" ms during system calls\n"; দ্রষ্টব্য − প্রতিটি পরীক্ষার জন্য একটি php উদাহরণ তৈরি করা হলে সময়ের পার্থক্য গণনা করার দরকার নেই৷
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেThe process used 1.563896 ms for the computations Spent 0.345628 ms during system calls