2019-11-01

压测环境

机器 sim08 passenger
cpu:
mem:

PHP

  • 用的是phpbench,9k+条key,17种语言,一共10w+条文案

  • 压测结果
    迭代10次,每次迭代请求1w次,平均请求时间为3230ns

|---|---|---|
|revs|请求次数|10000|
|its|迭代次数|10|
|mem_peak|内存峰值|37,521,616b|
|cpu_peak|cpu峰值|61.5%|
|best|最短时间|2.608μs|
|mean|平均时间|3.230μs|
|mode|最频繁的时间|2.965μs|
|worst|最差时间|4.434μs|


```shell
1 subjects, 10 iterations, 10,000 revs, 0 rejects, 0 failures, 0 warnings

(best [mean mode] worst) = 2.608 [3.230 2.965] 4.434 (μs)

⅀T: 32.297μs μSD/r 0.532μs μRSD/r: 16.472%

suite: 1341737daa00882869b7c9270b9fbbb33683d31e, date: 2019-10-31, stime: 20:00:15

+-----------------+-------------------+--------+--------+-------+-----+-------------+---------+---------+---------+---------+---------+--------+-------+

| benchmark       | subject           | groups | params | revs  | its | mem_peak    | best    | mean    | mode    | worst   | stdev   | rstdev | diff  |

+-----------------+-------------------+--------+--------+-------+-----+-------------+---------+---------+---------+---------+---------+--------+-------+

| CopyWriterBench | benchGetPlainText |        | []     | 10000 | 10  | 37,521,616b | 2.608μs | 3.230μs | 2.965μs | 4.434μs | 0.532μs | 16.47% | 1.00x |

+-----------------+-------------------+--------+--------+-------+-----+-------------+---------+---------+---------+---------+---------+--------+-------+

```
  • 压测代码 benchMark
    /**
    * Class CopyWriterBench
    * @Iterations(10)
    * @Revs(10000)
    * @BeforeMethods({"init"})
    *
    */
    class CopyWriterBench
    {
        private $copyWriter;
    
        private $cases;
    
        private $keys;
    
        private $randomInts;
    
        private $langs;
    
        public function init() {
            $this->copyWriter = Copywriter::getCopywriterInstance(__DIR__.'/conf');
            $json_string = file_get_contents(__DIR__.'/cases.json');
            $this->cases = json_decode($json_string, true);
            $this->randomInts = array();
            for( $i=0; $icases); $i++) {
                array_push($this->randomInts, random_int(0, count($this->cases)));
            }
            $this->langs = array("es_pe","es_cr","en_br","es_ar","es_pa","ts_nl","en_au","pt_br","ja_jp","es_419","zh_tw",
            "zh_hk","en_us","es_mx","es_co","zh_cn","es_cl");
            $this->keys = array_keys($this->cases);
        }
    
        public function benchGetPlainText() {
            $aCase = 0;
            try
            {
                $aCase++;
                $randomInt = $this->randomInts[$aCase % count($this->cases)];
                $this->copyWriter->getPlainText($this->cases[$this->keys[$randomInt]], $this->langs[$randomInt%count($this->langs)]);
            } catch (Exception $e) {
                trigger_error("get copy writer error".$this->cases[$randomInt]);
                throwException($e);
            }
        }
    }
    

你可能感兴趣的:(2019-11-01)