Giter VIP home page Giter VIP logo

defold-chronos's Introduction

Chronos for Defold

High resolution monotonic timers, based on https://github.com/ldrumm/chronos.

Installation

Add defold-chronos in your own project as a Defold library dependency. Open your game.project file and in the dependencies field under project add: https://github.com/redoak/defold-chronos/archive/master.zip

Example

local function profile_fn(fn)
    if chronos then
        local before = chronos.time()
        fn()
        local after = chronos.time()
        print("elapsed seconds: " .. (after - before))
    end
end

Platform support

Only Windows supports the full API below.

API

-- returns seconds, normally with a precision of 100โ€“300ns.
chronos.time()

-- returns the frequency of the used counter, e.g. 3,125,000.
chronos.frequency()

-- returns the number of decimal values that are reliable, e.g. a frequency
-- of 10,000,000 gives a period of 100ns with 7 reliable decimals.
chronos.decimals()

-- returns the rdtsc counter value.
chronos.tsc()

-- returns seconds passed since the given tsc value, and the core frequency
-- estimated over the given wait time in milliseconds (default 100), used to
-- calculate it.
chronos.tsc_time(tsc, [wait])

defold-chronos's People

Contributors

d954mas avatar redoak 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.