{"action":"created","issue":{"url":"https://api.github.com/repos/bos/statprof.py/issues/13","labels_url":"https://api.github.com/repos/bos/statprof.py/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/bos/statprof.py/issues/13/comments","events_url":"https://api.github.com/repos/bos/statprof.py/issues/13/events","html_url":"https://github.com/bos/statprof.py/issues/13","id":6612921,"number":13,"title":"When using from IPython, total time reported at the end accumulates.","user":{"login":"elpres","id":408526,"avatar_url":"https://avatars.githubusercontent.com/u/408526?v=3","gravatar_id":"","url":"https://api.github.com/users/elpres","html_url":"https://github.com/elpres","followers_url":"https://api.github.com/users/elpres/followers","following_url":"https://api.github.com/users/elpres/following{/other_user}","gists_url":"https://api.github.com/users/elpres/gists{/gist_id}","starred_url":"https://api.github.com/users/elpres/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elpres/subscriptions","organizations_url":"https://api.github.com/users/elpres/orgs","repos_url":"https://api.github.com/users/elpres/repos","events_url":"https://api.github.com/users/elpres/events{/privacy}","received_events_url":"https://api.github.com/users/elpres/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2012-09-03T10:25:05Z","updated_at":"2015-10-09T01:15:28Z","closed_at":null,"body":"If I profile a script such as this one:\n\n    def main():\n        # do something\n    \n    if __name__ == '__main__':\n        import statprof\n        statprof.start()\n        try:\n            main()\n        finally:\n            statprof.stop()\n            statprof.display()\n\nand call it from IPython by repeatedly executing `run script.py`, the total time grows each time by duration of the execution (e.g. 1s, 2s, 3s, ...).\n\nWithout looking very deeply into the code, the function `clock()` gets its time from `os.times()`. I am not certain what the values in the list returned by it represent, but the result of `clock()` seems to be the same as what `time.clock()`, which is the CPU time since the module has been imported and that matches well with the observed behavior. Maybe it would be better to use `time.time()` (which returns an absolute time value), then save the current time at `statprof.start()`, and calc the difference by `time.time() - starttime`?\n\nAlso, I've noticed this today, but I've been doing the same thing a couple of days ago and was getting more or less constant values for each run. But I can't remember whether I've been working from inside IPython or calling the script directly from the shell. So I'm not sure it really is well reproducible."},"comment":{"url":"https://api.github.com/repos/bos/statprof.py/issues/comments/146730190","html_url":"https://github.com/bos/statprof.py/issues/13#issuecomment-146730190","issue_url":"https://api.github.com/repos/bos/statprof.py/issues/13","id":146730190,"user":{"login":"durin42","id":20269,"avatar_url":"https://avatars.githubusercontent.com/u/20269?v=3","gravatar_id":"","url":"https://api.github.com/users/durin42","html_url":"https://github.com/durin42","followers_url":"https://api.github.com/users/durin42/followers","following_url":"https://api.github.com/users/durin42/following{/other_user}","gists_url":"https://api.github.com/users/durin42/gists{/gist_id}","starred_url":"https://api.github.com/users/durin42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durin42/subscriptions","organizations_url":"https://api.github.com/users/durin42/orgs","repos_url":"https://api.github.com/users/durin42/repos","events_url":"https://api.github.com/users/durin42/events{/privacy}","received_events_url":"https://api.github.com/users/durin42/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T01:15:28Z","updated_at":"2015-10-09T01:15:28Z","body":"Is this still an issue?"}}