about summary refs log tree commit diff stats
path: root/doc/tools/performance_test.py
blob: 3b9099d5adb842f1c2911381c1f4d800639a0ea2 (plain) (blame)
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
#!/usr/bin/env python

from __future__ import (absolute_import, division, print_function)

import sys
import time

sys.path.insert(0, '../..')
sys.path.insert(0, '.')


def main():
    import ranger.container.directory
    import ranger.core.shared
    import ranger.container.settings
    import ranger.core.fm
    from ranger.ext.openstruct import OpenStruct
    ranger.args = OpenStruct()
    ranger.args.clean = True
    ranger.args.debug = False

    settings = ranger.container.settings.Settings()
    ranger.core.shared.SettingsAware.settings_set(settings)
    fm = ranger.core.fm.FM()
    ranger.core.shared.FileManagerAware.fm_set(fm)

    time1 = time.time()
    fm.initialize()
    try:
        usr = ranger.container.directory.Directory('/usr')
        usr.load_content(schedule=False)
        for fileobj in usr.files:
            if fileobj.is_directory:
                fileobj.load_content(schedule=False)
    finally:
        fm.destroy()
    time2 = time.time()
    print("%dms" % ((time2 - time1) * 1000))


if __name__ == '__main__':
    main()