diff talosnames/api.py @ 21:48b4c926be73

getting there
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 10 Jul 2012 18:56:34 -0700
parents 25e91fc7ff01
children 82d15f93cc4a
line wrap: on
line diff
--- a/talosnames/api.py	Tue Jul 10 18:39:46 2012 -0700
+++ b/talosnames/api.py	Tue Jul 10 18:56:34 2012 -0700
@@ -41,7 +41,10 @@
         self.setup_database()
         self.tbpl_mapping()
         self.setup_buildbot()
+
+        # cache
         self._talos_configs = {}
+        self._tbpl_names = {}
 
     def setup_database(self):
         self.db = sqlite3.connect(':memory:')
@@ -95,9 +98,12 @@
 
     def tbpl_name(self, name):
         """returns the TBPL long name"""
+        if name in self._tbpl_names:
+            return self._tbpl_names[name]
         for tbplname, regex in self.tbpl_regexs.items():
             regex = re.compile(regex)
             if regex.match(name):
+                self._tbpl_names[name] = tbplname
                 return tbplname
 
     def buildbot_command(self, name):
@@ -106,6 +112,9 @@
 
     def talos_config(self, name):
         """returns talos configuration for suite `name`"""
+        if name in self._talos_configs:
+            return self._talos_configs[name]
+
         command = self.buildbot_command(name)
         assert command is not None, "Suite not found: %s" % name
         outfile = tempfile.mktemp(suffix='.yml')
@@ -114,6 +123,7 @@
         call(['PerfConfigurator'] + command, stdout=subprocess.PIPE, cwd=talos_dir)
         assert os.path.exists(outfile)
         config = yaml.load(file(outfile))
+        self._talos_configs[name] = config
         return config
 
     def test_config(self, name):