예제 #1
0
파일: stats_test.py 프로젝트: wilswu/ocflib
def test_fast_slow_profiles_same():
    start = datetime(2015, 11, 23)
    end = start + timedelta(days=1)

    slow_profiles = {
        host + '.ocf.berkeley.edu': UtilizationProfile.from_hostname(host, start, end)
        for host in list_desktops()
    }
    fast_profiles = UtilizationProfile.from_hostnames(list_desktops(), start, end)

    assert set(slow_profiles.keys()) == set(fast_profiles.keys())

    for host in slow_profiles.keys():
        slow = slow_profiles[host]
        fast = fast_profiles[host]

        assert slow.hostname == fast.hostname
        assert slow.start == fast.start
        assert slow.end == fast.end
        assert slow.sessions == fast.sessions
예제 #2
0
def test_fast_slow_profiles_same():
    start = datetime(2015, 11, 23)
    end = start + timedelta(days=1)

    slow_profiles = {
        host + '.ocf.berkeley.edu': UtilizationProfile.from_hostname(host, start, end)
        for host in list_desktops()
    }
    fast_profiles = UtilizationProfile.from_hostnames(list_desktops(), start, end)

    assert set(slow_profiles.keys()) == set(fast_profiles.keys())

    for host in slow_profiles.keys():
        slow = slow_profiles[host]
        fast = fast_profiles[host]

        assert slow.hostname == fast.hostname
        assert slow.start == fast.start
        assert slow.end == fast.end
        assert slow.sessions == fast.sessions
예제 #3
0
from datetime import datetime
from datetime import timedelta

from ocflib.lab.stats import list_desktops
from ocflib.lab.stats import UtilizationProfile


@contextmanager
def timeit():
    start = time.time()
    yield
    print('Time taken: {}'.format(time.time() - start))


if __name__ == '__main__':
    start = datetime(2015, 11, 23)
    end = start + timedelta(days=1)

    print('Testing naive time to create profiles.')
    with timeit():
        slow_profiles = {
            host + '.ocf.berkeley.edu':
            UtilizationProfile.from_hostname(host, start, end)
            for host in list_desktops()
        }

    print('Testing optimized time to create profiles.')
    with timeit():
        fast_profiles = UtilizationProfile.from_hostnames(
            list_desktops(), start, end)
예제 #4
0
import time
from contextlib import contextmanager
from datetime import datetime
from datetime import timedelta

from ocflib.lab.stats import list_desktops
from ocflib.lab.stats import UtilizationProfile


@contextmanager
def timeit():
    start = time.time()
    yield
    print('Time taken: {}'.format(time.time() - start))


if __name__ == '__main__':
    start = datetime(2015, 11, 23)
    end = start + timedelta(days=1)

    print('Testing naive time to create profiles.')
    with timeit():
        slow_profiles = {
            host + '.ocf.berkeley.edu': UtilizationProfile.from_hostname(host, start, end)
            for host in list_desktops()
        }

    print('Testing optimized time to create profiles.')
    with timeit():
        fast_profiles = UtilizationProfile.from_hostnames(list_desktops(), start, end)