Git Product home page Git Product logo

park-bench's Introduction

Park Bench

An elderly man sitting on a park bench watching your code execute, then telling you about it over chess stategy pointers and life stories.

Usage

Inline Benches

scala> new park.Bench() {
  def run = Thread.sleep(1000)
  override def subject = "sleeping beauty"
} watch(1, 1)

               		cpu		    user		  system		real
sleeping beauty		0.000634	0.000133	0.000087	1.000265

Benches as objects

case class Book(name: String, pages: Int)

class BookShelf { def read(book: Book) = Thread.sleep(1000 * book.pages) }

object BookShelfBench extends BookShelf with park.Bench {
  def run = read(Book("a tale of 2 pages", 2))
  override def subject = "reading books from the shelf"
}

BookShelfBench.watch(1, 1)
                            		cpu		    user		  system		real
reading books from the shelf		0.000672	0.000614	0.000083	2.000975


// with 2 iterations of `run`
BookShelfBench.watch(2, 1)
                            		cpu		    user		  system		real
reading books from the shelf		0.000261	0.000182	0.000124	4.000479

// with 2 observations of 2 iterations of `run`
BookShelfBench.watch(2, 2)
                            		cpu		    user		  system		real
reading books from the shelf		0.000228	0.000156	0.000101	4.000368
reading books from the shelf		0.000208	0.000164	0.000083	4.000519

Or how about running this as a main appliction

BookShelfBench.main(Array("1","1"))

Install

TODO

TODO

  • tests

2010-2011 Doug Tangren (softprops)

park-bench's People

Contributors

softprops avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

pinklite

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.