Commit 848f9944 authored by Yanghan Wang's avatar Yanghan Wang Committed by Facebook GitHub Bot
Browse files

remove the TestStartupTime

Summary: Pull Request resolved: https://github.com/facebookresearch/d2go/pull/220

Differential Revision: D35853885

fbshipit-source-id: 08d5188d8cd7310f306d07e22cee96bc4d7e06c8
parent 2d1dfb91
...@@ -2,28 +2,6 @@ ...@@ -2,28 +2,6 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import time
SETUP_ENV_TIME = []
REGISTER_D2_DATASETS_TIME = []
REGISTER_TIME = []
def _record_times(time_list):
def warp(f):
def timed_f(*args, **kwargs):
start = time.perf_counter()
ret = f(*args, **kwargs)
time_list.append(time.perf_counter() - start)
return ret
return timed_f
return warp
@_record_times(SETUP_ENV_TIME)
def _setup_env(): def _setup_env():
# Set up custom environment before nearly anything else is imported # Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder) # NOTE: this should be the first import (no not reorder)
...@@ -32,13 +10,11 @@ def _setup_env(): ...@@ -32,13 +10,11 @@ def _setup_env():
) )
@_record_times(REGISTER_D2_DATASETS_TIME)
def _register_d2_datasets(): def _register_d2_datasets():
# this will register D2 builtin datasets # this will register D2 builtin datasets
import detectron2.data # noqa F401 import detectron2.data # noqa F401
@_record_times(REGISTER_TIME)
def _register(): def _register():
from d2go.data import dataset_mappers # NOQA from d2go.data import dataset_mappers # NOQA
from d2go.data.datasets import ( from d2go.data.datasets import (
......
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
from d2go.initializer import (
REGISTER_D2_DATASETS_TIME,
REGISTER_TIME,
SETUP_ENV_TIME,
)
class TestStartupTime(unittest.TestCase):
@unittest.skipIf(True, "Will exceed threshold")
def test_setup_env_time(self):
self.assertLess(sum(SETUP_ENV_TIME), 5.0)
def test_register_d2_datasets_time(self):
self.assertLess(sum(REGISTER_D2_DATASETS_TIME), 3.0)
@unittest.skipIf(True, "Will exceed threshold")
def test_register_time(self):
# NOTE: _register is should be done quickly, currently about 0.2s
self.assertLess(sum(REGISTER_TIME), 1.0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment