Giter VIP home page Giter VIP logo

kprofile's Introduction

KProfile - A Profiling library made with and for Kotlin

KProfile lets you efficiently create, store, view and compare profiling results made with a simple Dsl. This helps to understand the performance changes caused by different changes to the code.

Creating Profiling results

For creating profiling results for a method you have to simply define an object which inherits from ProfilingSuite.

object Initial: Tag("Initial")

object PrimeTestProfiling: ProfilingSuite("prime test", Initial {
    val x = 23090909
    profile("testing primality of a very big integer") {
        primeTest(x)
    }
})

Now you can call the run method of ProfilingSuite to store the results in a file in the AppData directory.

You don't have to do anything except calling the run method and KProfile stores all the information for you.

But what about the parameters of the constructor for ProfilingSuite?

The first parameter which we have passes "prime test" to is the topic.

It should describe what you profile in this suite.

We will hear more about the topic in the section Viewing Profiling results.

The second parameter is a tag. It defines which version of the program is profiled. Tags will become essential when comparing many versions of a program.

For now we simply pass Initial because we are profiling the first version of out program. When we apply changes we create new tags and pass them to the ProfilingSuite.

Viewing and comparing profiling results

Now if KProfile would just store the profiling results in some unreadable format in some unknown file with a crazy name it would be pretty useless.

KProfile provides a Kotlin-API to view and compare profiling results using plain text or converting the results to markdown.

This API works best with the Kotlin-REPL by Jetbrains.

You can view results with the view function of the interface ResultFormat.

There are two implementations of that interface.

  • plaintext
  • markdown

The latter is a function and takes a markdown theme or applies the default theme.

kprofile's People

Contributors

nkb03 avatar

Watchers

 avatar

Forkers

jsdelivrbot

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.