<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          simperf性能測(cè)試工具

          聯(lián)合創(chuàng)作 · 2023-10-01 20:34

          Simperf 是一個(gè)簡(jiǎn)單的性能測(cè)試工具,它提供了一個(gè)多線程測(cè)試框架

          Example:

          1. 在代碼里使用Simperf

          Simperf perf = new Simperf(50, 2000, 1000, 
              new SimperfThreadFactory() {
                  public SimperfThread newThread() {
                      return new SimperfThread();
                  }
              });
          // 設(shè)置結(jié)果輸出文件,默認(rèn) simperf-result.log
          perf.getMonitorThread().setLogFile("simperf.log");
          // 開始性能測(cè)試
          perf.start();
          

          2. 在命令行里使用Simperf

          public class SimperfCommandTest {
              public static void main(String[] args) {
                  SimperfCommand simCommand = new SimperfCommand(args);
                  Simperf perf = simCommand.create();
                  if (perf == null) {
                      // 參數(shù)解析失敗時(shí)會(huì)返回null
                      System.exit(-1);
                  }
                  perf.start(new SimperfThreadFactory() {
                      public SimperfThread newThread() {
                          return new SimperfThread();
                      }
                  });
              }
          }
          

          執(zhí)行命令:

          java SimperfCommandTest -t 10 -c 10 -i 1000
          參數(shù)說明:
          usage: SimperfCommand options
           -c,--count       [*] number of each thread requests count
           -i,--interval    [ ] interval of print messages, default 1000
           -j               [ ] generate jtl report
           -l,--log         [ ] log filename
           -m,--maxtps      [ ] max tps
           -t,--thread      [*] number of thread count
          

          3. 在Junit4里使用Simperf

          public class SimperfTestCaseTest extends SimperfTestCase {
              private Random              rand;
              @Test
              @Simperf(thread = 2, count = 5, interval = 1000)
              public void testXxx() {
                  try {
                      Thread.sleep(1000);
                  } catch (Exception e) {
                  }
                  boolean result = rand.nextInt(10) > 1;
                  Assert.assertTrue("隨機(jī)生成結(jié)果", result);
              }
          }
          瀏覽 23
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  成人77777 | 中文天堂在线视频 | 天天做天天爽 | 特级黄色A片 | 亚洲精品夜色 |