Skip to content

Commit

Permalink
Merge pull request #1 from mbarkhau/master
Browse files Browse the repository at this point in the history
Tested with python2.7 and python3.6
  • Loading branch information
kwlzn committed Jan 16, 2018
2 parents 1faa760 + c1b3d38 commit a945c92
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
6 changes: 6 additions & 0 deletions pytracing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from .pytracing import TraceProfiler

__all__ = ['TraceProfiler']
19 changes: 15 additions & 4 deletions pytracing/pytracing.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
from contextlib import contextmanager
from Queue import Queue
import json
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import sys
import threading
import json
import time
import threading
from contextlib import contextmanager

try:
from queue import Queue
except ImportError:
from Queue import Queue


def to_microseconds(s):
return 1000000 * float(s)


class TraceWriter(threading.Thread):

def __init__(self, terminator, input_queue, output_stream):
threading.Thread.__init__(self)
self.daemon = True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='pytracing',
version='0.1',
version='0.2',
description='a python trace profiler that outputs to chrome trace-viewer format (about://tracing).',
author='Kris Wilson',
author_email='kwilson@twitter.com',
Expand Down
12 changes: 9 additions & 3 deletions test_pytracing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env python2.7

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import io
import time

from pytracing import TraceProfiler
Expand All @@ -21,7 +27,7 @@ def main():


if __name__ == '__main__':
with open('./trace.out', 'wb') as fh:
with io.open('./trace.out', mode='w', encoding='utf-8') as fh:
tp = TraceProfiler(output=fh)
tp.install()
main()
Expand Down

0 comments on commit a945c92

Please sign in to comment.