Coder Social home page Coder Social logo

spock-profile-extension's Introduction

Spock Profile Extention

The GProf is a profiler for Groovy. This extention make to use the GProf in spock.

To use we can do the following:

class ProfileSpec extends Specification {

    @Profile
    def "with profile"() {
        when:
        new YourApp().start()

        then:
        noExceptionThrown()
    }

}

class YourApp {
    void start() {
        def foo = new Foo()
        for (int i = 0; i < 100; i++) {
            foo.doShortTask()
        }
        def bar = new Bar()
        bar.doLongTask()
    }
}

class Bar {
    void doLongTask() {
        for (int i = 0; i < 1000000; i++);
    }
}

class Foo {
    void doShortTask() {
        for (int i = 0; i < 10000; i++);
    }
}

output such as:

%      calls  total ms  ms/call  min ms  max ms  method       class
42.89      1     27.57    27.57   27.57   27.57  doLongTask   Bar
41.76    100     26.84     0.27    0.25    0.97  doShortTask  Foo
14.94      1      9.60     9.60    9.60    9.60  start        YourApp
 0.16      1      0.10     0.10    0.10    0.10  ctor         YourApp
 0.13      1      0.09     0.09    0.09    0.09  ctor         Bar
 0.12      1      0.08     0.08    0.08    0.08  ctor         Foo

If you would like to set a options that you can use @Profile attributes:

@Profile(includeMethods = ["*.ctor"], excludeMethods = ["java.*", "groovy.*"])

Please see this page for the option details.

spock-profile-extension's People

Contributors

yamkazu avatar

Stargazers

Jakub Jirutka avatar Stig Kleppe-Jørgensen avatar

Watchers

Stig Kleppe-Jørgensen avatar James Cloos avatar  avatar

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.