You are here: Home » Software Development » Other » p-unit

p-unit

p-unit p-unit is an open source framework for performance benchmark and unit test



  • Downloads:37
  • Last update:Apr 18, 2009
  • Version:0.1
  • License:GPL
  • Publisher:Andrew Zhang
  • System Requirements Windows All / Unix

Free Download ( 2.6 MB )

p-unit

p-unit is an open source framework for performance benchmark and unit test
p-unit is an open source framework for performance benchmark and unit test, which supports to run the same tests solo or concurrently, generates the result in the form of plain text, image or pdf file and tracks memory and time consumption.

Test Suite and Test Class

Test suite and test class are two important concepts in p-unit. p-unit does not require any special type for a test class, so every class can be a test class. Of course, it includes junit test cases. There is one special interface for special p-unit only test class - p-unitTest.

p-unit executes a normal test as following procedure:
  • invoke setUp if there is.
  • invoke the test method.
  • invoke tearDown method.

    Noticed that setUp and tearDown will also be regarded as a part of performance test. If you don't want to count them into performance data, you need to implement p-unitTest interface, which will be executed as:
  • invoke setUpBeforeWatchers.
  • invoke setAfterWatchers.
  • invoke the test method.
  • invoke tearDownBeforeWatchers.
  • invoke tearDownAfterWatchers. As the name suggests, you can put the setUp and tearDown code into the setUpBeforeWatchers and tearDownAfterWatchers.

    Time/Memory Record

    p-unit records the memory and time consumption of running a test method. There is a "watcher" concept in p-unit, which supervises the status during running the test method.

    By default, memory watcher and time watcher are installed. p-unit supports user-defined watcher too. The user only needs to implement the Watcher interface and register it to p-unit method runner.

    By default, time watcher is enabled. If you want to watch memory consumption, you need to add one line code:
    runner.methodRunner().addWatcher(new MemoryWatcher());

    Concurrent
    p-unit supports to run the test concurrently. How to write it? You DON'T need to write anything about concurrent in your test - just the same as a normal test. You only need to use p-unitConcurrentRunner to run your test concurrently. For more detail, please refer to Runner.

    Runner

    Runner is the core concept of p-unit. You need a runner to run your test. By default, there are two different runners - solo runner and concurrent runner, so that one test can be executed solo and concurrently.

    Is it complex to launch a runner? ONE line code:

    new SoloRunner().run(MyTest.class); or new ConcurrentRunner().run(MyTest.class);

    By default, p-unitConcurrentRunner starts up 10 threads to execute the test method. You can configure it in the constructor of p-unitConcurrentRunner(int threadCount), and you can even do fine control in your test class.

    If you need to execute different test class with different thread count, you only need to implement Concurrent interface for your test, which requires to return concurrentCount.

    Free Download ( 2.6 MB )

  • Rating & Reviews for p-unit





    Tips & Guides Related to p-unit

    • Voice over Internet phone and chat software on Mac

      Internet phone has become so ubiquitous, an entire generation of internet users is probably unaware there was ever life without it. Use Internet phone to help you communicate across networks with people all the world.

      by candies on Aug 26, 2009

    • How can I remove Spam from my PC

      How can you remove spam emails from PC? Spam Monitor - this excellent detector and remove software monitors and removes Spam, Junk Mail and Virus Mail from your PC!

      by candies on Jun 19, 2009

    • How to use Menu Wizard?

      Guide to use Menu Wizard.

      by Admin on Nov 6, 2007

    • How do I protect my computer from Spam

      How do I protect my computer from Spam Mail? Spam Monitor - this powerful and latest Spam monitor filter software offers a series of protective functions, it can protect your PC from all Spam Emails!

      by candies on Jun 18, 2009

    • How to stop Junk Mail in your mailbox

      How to stop Spam and Junk Mail in your mailbox? Spam Monitor - this full-functional spam detector and filter software can help you monitor all the Junk Mails and stop them from sending to your mailbox.

      by candies on Jun 19, 2009

    Free Download p-unit

    Free Download ( 2.6 MB )