freebencher - 性能測試工具
Freebencher 是一個極其靈活易用的性能測試工具。之所以靈活,是因為你可以用任意 Java 代碼來寫性能測試用例,你可以測試任何可以用 Java 代碼來表示的行為,你可以用任何你自己喜歡的方式在測試時獲取你的測試數據。
生成的結果類似于 apache ab 的結果, 使用你喜歡的 concurrency,qps 等概念。
你可以通過 Maven 把 freebencer 迅速導入到你的項目中,調用你自己的業務方法,而不是像 Jmeter 一樣,把你的類文件別扭地復制到它的目錄中。
例:
@Test public void testLogin() { final List<User> userList = new ArrayList<User>(); ...//preparing userList to be used as test data. FbJobResult result = Freebencher.benchmark(new FbTarget() { //the behavior @Override public boolean invoke() { User user = userList.get(RandomUtils .nextInt(userList.size())); int statusCode = remoteServiceToTest.doLogin(user.getUsername(), user.getClearPassword()); return statusCode == 200; } }, 5, // concurrency, 50 // number of tests to run ); System.out.println(result.report()); }
得到結果:
Test started. Awaiting termination... Test completed. Concurrency: 5 Time taken for tests: 119ms Successful tests: 50 Failed tests: 0 Tests per second: 420.16806722689074 Mean time per test: 11.38ms Percentage of the test finished within a certain time (ms) 50%: 11 60%: 12 70%: 12 80%: 13 90%: 14 95%: 14 98%: 14 99%: 16 100%: 16
本文由用戶 gu365377 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!