File: measure_memory_consumption.py

package info (click to toggle)
pandas 0.13.1-2~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 48,044 kB
  • sloc: python: 115,757; ansic: 11,490; sh: 311; makefile: 120
file content (55 lines) | stat: -rwxr-xr-x 1,286 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function

"""Short one-line summary

long summary
"""


def main():
    import shutil
    import tempfile
    import warnings

    from pandas import Series

    from vbench.api import BenchmarkRunner
    from suite import (REPO_PATH, BUILD, DB_PATH, PREPARE,
                       dependencies, benchmarks)

    from memory_profiler import memory_usage

    warnings.filterwarnings('ignore', category=FutureWarning)

    try:
        TMP_DIR = tempfile.mkdtemp()
        runner = BenchmarkRunner(
            benchmarks, REPO_PATH, REPO_PATH, BUILD, DB_PATH,
            TMP_DIR, PREPARE, always_clean=True,
            # run_option='eod', start_date=START_DATE,
            module_dependencies=dependencies)
        results = {}
        for b in runner.benchmarks:
            k = b.name
            try:
                vs = memory_usage((b.run,))
                v = max(vs)
                # print(k, v)
                results[k] = v
            except Exception as e:
                print("Exception caught in %s\n" % k)
                print(str(e))

        s = Series(results)
        s.sort()
        print((s))

    finally:
        shutil.rmtree(TMP_DIR)


if __name__ == "__main__":
    main()