此次基准测试只是简单测算一下node与php在冒泡排序方面的时间损耗情况,基本思想是使用冒泡排序各自运算100次之后求出平均值;冒泡排序算法摘自网上,测试代码如下:
代码
JavaScript:
function sort(arr){ var n=arr.length; //获取数组的长度,即有n个数在排序 var temp=null; //定义一个临时变量,交换数据用 for(var i=0; i<n-1; i++){ //外层循环n-1次 for(var j=0; j<n-1-i; j++){ //内层每次循环n-1-i次,每次循环完,都能从剩下的数当中找出一个最大的放在n-1-i的位置 if(arr[j]>arr[j+1]){ //如果a[j]>a[j+1]则交换位置 temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } return arr; //返回排好序的数组}const array = [49, 38, 65, 97, 76, 13, 27,49, 38, 65, 97, 76, 13, 27];const startTime = new Date();for (let i = 0; i <= 99; i++) { const arr = sort(array);}console.log((new Date() - startTime) / 1000 / 100);
PHP:
function bubble_sort($array){ $count = count($array); if ($count <= 0) return false; for ($i = 0; $i < $count; $i++) { for ($j = $count - 1; $j > $i; $j--) { //如果后一个元素小于前一个,则调换位置 if ($array[$j] < $array[$j - 1]) { $tmp = $array[$j]; $array[$j] = $array[$j - 1]; $array[$j - 1] = $tmp; } } } return $array;}$array = [49, 38, 65, 97, 76, 13, 27,49, 38, 65, 97, 76, 13, 27];$startTime = microtime(true);for ($i = 0; $i <= 99; $i++) { $arr = bubble_sort($array);}echo number_format((microtime(true) - $startTime) / 100, 10);
注意:为了测试php5并没有采用php7的强调语法类型
测试结果
如图:
PHP5.6
Node7.9:
PHP7.1
结论
三次测算的结果分别是:
测试机器
从本次测试的结果来看在执行速度上 PHP7.1 > PHP5.6 > Node7.9
以上就是NodeJs与PHP的benchmark的详细内容,更多请关注求知技术网其它相关文章!
Viagra Principio Attivo [url=https://buycialikonline.com]cialis online[/url] Levitra Scheda Tecnica
Topical Keflex Use
Although these therapies are largely effective in controlling SLE hypertension and reducing albuminuria, combination therapy i
We hypothesized that a unique set of factors, including fertility concerns, would contribute to the poor tamoxifen use among premenopausal patients
2003; MacLusky et al Risk of development of hyperkalaemia; monitor serum potassium regularly
The prescribing doctor should also use the checklist available to ensure that all necessary information has been provided to the patient and or carer
minomycin zyrtec inactive ingredients Brilliant
For various reasons we are not willing to do it and we will not agree to the shipment of even one gram of uranium from Iran, he said in the interview
Port insertion, then infection at port and axilla, two different antibiotics to elimnate infection
In fact they show the opposite
Recalls, warnings and label changes How long does hair thin after chemo
Right Sublethally irradiated 650 Rad recipient mice n 5 transplanted with 1 10 6 splenocytes isolated from moribund leukemic Tet2; AE mice LeuA Valerate 10 20 mg IM q4weeks
Carbon dioxide laser treatment of Bartholin s gland cyst
19 The report found that the mortality rate in patients with ICU acquired hyponatremia or hypernatremia was greater than that of study patients with normal serum sodium levels, being 28 versus 16 P
If you know a cheaper plumber or electrician, for example, ask your agent to use them for future work
Cadherins inhibited by Wnt signaling can also act as repressors of cell division Shi et al
2009; 47 2037 43
We call these high risk HPV genomic structures HRGS
Wash your hands before using Doxicor kit
3 trial, the researchers randomly split the approximately 4, 500 high risk, postmenopausal women in the study into two groups
No matter what Liang Zhao does or does, in the end, it is for himself We demonstrate that TAM ER binds EREs with lower affinity than E2 ER, 4 OHT ER, or ER liganded by the covalent antiestrogen tamoxifen aziridine
Highly effective Optimum quality Safe to consume Accurate composition Of the baseline survey respondents n 408 732, 55
ARG ANNOT, a new bioinformatic tool to discover antibiotic resistance genes in bacterial genomes
The benzoquinone ring of CoQ is synthesized from the amino acid tyrosine or phenylalanine, and the tail is produced from acetyl- CoA by the mevalonate pathway through the action of tetrameric decaprenyl diphosphate synthase, encoded by the Pdss1 and Pdss2 genes О± synuclein aggregates are primary components of Lewy bodies, the defining pathological feature of PD 40
SYNTHROID is not indicated for suppression of benign thyroid nodules and nontoxic diffuse goiter in iodine sufficient patients as there are no clinical benefits and overtreatment with SYNTHROID may induce hyperthyroidism see Warnings and Precautions 5 However, using transient transfection assays, all classes of antiestrogens bound to ER ОІ are potent transcriptional activators at an AP 1 site, acting as estrogen agonists rather than antagonists 9
Until I was 43 years old, and diagnosed with breast cancer was the first time I canceled everything, and laid in my room for weeks You and Dick were our favorite grownup friends of mom s and dad s, we truly loved you both and used to count the days until we could visit again