Git Product home page Git Product logo

yunomi's Introduction

YUNOMI: Y U NO MEASURE IT

image

image

As in:

It has performance implications, Y U NO MEASURE IT!?

Yunomi provides insights to the internal behavior of an application, providing useful statistics and metrics on selected portions of your code. It’s a Python port of the core portion of a Java Metrics library by Coda Hale.

Stop guessing, start measuring:

$ pip install yunomi

Core Features

Counter

Simple interface to increment and decrement a value. For example, this can be used to measure the total number of jobs sent to the queue, as well as the pending (not yet complete) number of jobs in the queue. Simply increment the counter when an operation starts and decrement it when it completes.

Meter

Measures the rate of events over time. Useful to track how often a certain portion of your application gets requests so you can set resources accordingly. Tracks the mean rate (the overall rate since the meter was reset) and the rate statistically significant regarding only events that have happened in the last 1, 5, and 15 minutes (Exponentially weighted moving average).

Histogram

Measures the statistical distribution of values in a data stream. Keeps track of minimum, maximum, mean, standard deviation, etc. It also measures median, 75th, 90th, 95th, 98th, 99th, and 99.9th percentiles. An example use case would be for looking at the number of daily logins for 99 percent of your days, ignoring outliers.

Timer

A useful combination of the Meter and the Histogram letting you measure the rate that a portion of code is called and a distribution of the duration of an operation. You can see, for example, how often your code hits the database and how long those operations tend to take.

Examples

Decorators

The simplest and easiest way to use the yunomi library.

Counter

You can use the count_calls decorator to count the number of times a function is called.

>>> from yunomi import counter, count_calls
>>> @count_calls
... def test():
...     pass
... 
>>> for i in xrange(10):
...     test()
... 
>>> print counter("test_calls").get_count()
10

Timer

You can use the time_calls decorator to time the execution of a function and get distributtion data from it.

>>> import time
>>> from yunomi import timer, time_calls
>>> @time_calls
... def test():
...     time.sleep(0.1)
... 
>>> for i in xrange(10):
...     test()
... 
>>> print timer("test_calls").get_mean()
0.100820207596

Requirements

Yunomi has no external dependencies and runs on PyPy and Python 2.6, 2.7, and 3.3.

yunomi's People

Contributors

richzeng avatar dreid avatar hynek avatar bramwelt avatar cyli avatar

Watchers

James Cloos avatar Philippe Ombredanne 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.