Giter VIP home page Giter VIP logo

timecounter's Introduction

TimeCounter

Python 时间统计函数(支持 PyTorch CUDA)

  • 无侵入的增加打印时间功能
  • 支持 cuda 同步统计时间
  • 支持平均时间打印
  • 支持打印间隔,WarmUp 时长设置
  • 支持 with 上下文,可用于某个函数内部某一段程序统计时长操作 (暂未实现)

原文地址:https://zhuanlan.zhihu.com/p/404204964

例子:

if __name__ == '__main__': 
 
    @TimeCounter.count_time() 
    def fun1(): 
        time.sleep(2) 
 
    @TimeCounter.count_time() 
    def fun2(): 
        time.sleep(1) 
 
    for _ in range(20): 
        fun1() 
        for _ in range(2): 
            fun2() 

用法:

在任意函数上,加上 @TimeCounter.count_time() 即可,如果想定制化参数,例如可以:

@TimeCounter.count_time(log_interval=10, warmup_interval=5, with_sync=True) 

timecounter's People

Contributors

captainji avatar

Watchers

 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.