Giter Site home page Giter Site logo

endprocess / freebencher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chenjianjx/freebencher

0.0 2.0 0.0 14 KB

A freestyle benchmarking tool that can test anything written in Java and produces apache-ab-like results

License: Apache License 2.0

Java 100.00%

freebencher's Introduction

freebencher

A Quick Example

pom.xml

	<repositories>
		<repository>
			<id>jitpack.io</id>
			<url>https://jitpack.io</url>
		</repository>
		...
	</repositories>


	<dependencies>
		<dependency>
			<groupId>com.github.chenjianjx</groupId>
			<artifactId>freebencher</artifactId>
			<version>1.0</version>
		</dependency>
		...
	</dependencies>	

Basically, you'll just need to write a callback method.

	@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());
	}

You will get ApacheBench-like output:

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

Why freebencher

  1. Simpler compared to GUI tools such as JMeter.
  2. More Parameterizable compared to Apache ab, which can take only one fixed URL.
  3. Most important, it is Embeddable. You integrate the testing framework into your own java project, so you can freely use your own business classes. On the contrary, other tools such as JMeter requires you to package your code into their library. The packaging and integration is very troublesome and cannot be automated. This is why freebencher was written.
  4. Freedom to developers.
  • You can test any behavior that can be written in Java, not just Http Servers.
  • You can prepare your test data in any way in Java, as long as the callback method can reference it. Aren't you sick of generating data files and "browse" it for GUI tools?
  • You can make assertions of the correctness of the testing results anyway you want using Java code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.