瀏覽代碼

fix unit of e2e and warmup in benchmark

gaotingquan 1 年之前
父節點
當前提交
7e680c7b4f
共有 2 個文件被更改,包括 42 次插入35 次删除
  1. 26 26
      docs/module_usage/instructions/benchmark.md
  2. 16 9
      paddlex/inference/utils/benchmark.py

+ 26 - 26
docs/module_usage/instructions/benchmark.md

@@ -30,23 +30,23 @@ python main.py \
 +----------------+-----------------+-----------------+------------------------+
 |   Component    | Total Time (ms) | Number of Calls | Avg Time Per Call (ms) |
 +----------------+-----------------+-----------------+------------------------+
-|    ReadCmp     |   100.20136833  |        10       |      10.02013683       |
-|     Resize     |   17.05980301   |        20       |       0.85299015       |
-|   Normalize    |   45.44949532   |        20       |       2.27247477       |
-|   ToCHWImage   |    0.03671646   |        20       |       0.00183582       |
-|    Copy2GPU    |   12.28785515   |        10       |       1.22878551       |
-|     Infer      |   76.59482956   |        10       |       7.65948296       |
-|    Copy2CPU    |    0.39863586   |        10       |       0.03986359       |
-| DetPostProcess |    0.43916702   |        20       |       0.02195835       |
+|    ReadCmp     |   99.60412979   |        10       |       9.96041298       |
+|     Resize     |   17.01641083   |        20       |       0.85082054       |
+|   Normalize    |   44.61312294   |        20       |       2.23065615       |
+|   ToCHWImage   |    0.03385544   |        20       |       0.00169277       |
+|    Copy2GPU    |   13.46874237   |        10       |       1.34687424       |
+|     Infer      |   71.31743431   |        10       |       7.13174343       |
+|    Copy2CPU    |    0.39076805   |        10       |       0.03907681       |
+| DetPostProcess |    0.36168098   |        20       |       0.01808405       |
 +----------------+-----------------+-----------------+------------------------+
 +-------------+-----------------+---------------------+----------------------------+
 |    Stage    | Total Time (ms) | Number of Instances | Avg Time Per Instance (ms) |
 +-------------+-----------------+---------------------+----------------------------+
-|  PreProcess |   162.74738312  |          20         |         8.13736916         |
-|  Inference  |   89.28132057   |          20         |         4.46406603         |
-| PostProcess |    0.43916702   |          20         |         0.02195835         |
-|   End2End   |    0.27992606   |          20         |         0.01399630         |
-|    WarmUp   |    5.37562728   |          5          |         1.07512546         |
+|  PreProcess |   161.26751900  |          20         |         8.06337595         |
+|  Inference  |   85.17694473   |          20         |         4.25884724         |
+| PostProcess |    0.36168098   |          20         |         0.01808405         |
+|   End2End   |   256.90770149  |          20         |        12.84538507         |
+|    WarmUp   |  5412.37807274  |          10         |        541.23780727        |
 +-------------+-----------------+---------------------+----------------------------+
 ```
 
@@ -54,21 +54,21 @@ python main.py \
 
 ```csv
 Component,Total Time (ms),Number of Calls,Avg Time Per Call (ms)
-ReadCmp,100.20136833190918,10,10.020136833190918
-Resize,17.059803009033203,20,0.8529901504516602
-Normalize,45.44949531555176,20,2.272474765777588
-ToCHWImage,0.036716461181640625,20,0.0018358230590820312
-Copy2GPU,12.28785514831543,10,1.228785514831543
-Infer,76.59482955932617,10,7.659482955932617
-Copy2CPU,0.3986358642578125,10,0.03986358642578125
-DetPostProcess,0.4391670227050781,20,0.021958351135253906
+ReadCmp,99.60412979125977,10,9.960412979125977
+Resize,17.01641082763672,20,0.8508205413818359
+Normalize,44.61312294006348,20,2.230656147003174
+ToCHWImage,0.033855438232421875,20,0.0016927719116210938
+Copy2GPU,13.468742370605469,10,1.3468742370605469
+Infer,71.31743431091309,10,7.131743431091309
+Copy2CPU,0.39076805114746094,10,0.039076805114746094
+DetPostProcess,0.3616809844970703,20,0.018084049224853516
 ```
 
 ```csv
 Stage,Total Time (ms),Number of Instances,Avg Time Per Instance (ms)
-PreProcess,162.74738311767578,20,8.137369155883789
-Inference,89.28132057189941,20,4.464066028594971
-PostProcess,0.4391670227050781,20,0.021958351135253906
-End2End,0.279926061630249,20,0.013996303081512451
-WarmUp,5.375627279281616,5,1.0751254558563232
+PreProcess,161.26751899719238,20,8.06337594985962
+Inference,85.17694473266602,20,4.258847236633301
+PostProcess,0.3616809844970703,20,0.018084049224853516
+End2End,256.90770149230957,20,12.845385074615479
+WarmUp,5412.3780727386475,10,541.2378072738647
 ```

+ 16 - 9
paddlex/inference/utils/benchmark.py

@@ -38,7 +38,7 @@ class Benchmark:
         self._reset()
 
     def warmup_stop(self, warmup_num):
-        self._warmup_elapse = time.time() - self._warmup_start
+        self._warmup_elapse = (time.time() - self._warmup_start) * 1000
         self._warmup_num = warmup_num
         self._reset()
 
@@ -103,18 +103,25 @@ class Benchmark:
             ("End2End", self._e2e_elapse, e2e_num, self._e2e_elapse / e2e_num),
         ]
         if self._warmup_elapse:
-            summary.append(
-                (
-                    "WarmUp",
-                    self._warmup_elapse,
-                    self._warmup_num,
-                    self._warmup_elapse / self._warmup_num,
-                )
+            warmup_elapse, warmup_num, warmup_avg = (
+                self._warmup_elapse,
+                self._warmup_num,
+                self._warmup_elapse / self._warmup_num,
             )
+        else:
+            warmup_elapse, warmup_num, warmup_avg = 0, 0, 0
+        summary.append(
+            (
+                "WarmUp",
+                warmup_elapse,
+                warmup_num,
+                warmup_avg,
+            )
+        )
         return detail, summary
 
     def collect(self, e2e_num):
-        self._e2e_elapse = time.time() - self._e2e_tic
+        self._e2e_elapse = (time.time() - self._e2e_tic) * 1000
         detail, summary = self.gather(e2e_num)
 
         detail_head = [