1# Copyright 2013 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import os 6 7from telemetry.core import discover 8from telemetry.internal.platform import profiler 9from telemetry.core import util 10 11 12def _DiscoverProfilers(): 13 profiler_dir = os.path.dirname(__file__) 14 return discover.DiscoverClasses(profiler_dir, util.GetTelemetryDir(), 15 profiler.Profiler, 16 index_by_class_name=True).values() 17 18 19def FindProfiler(name): 20 for p in _DiscoverProfilers(): 21 if p.name() == name: 22 return p 23 return None 24 25 26def GetAllAvailableProfilers(): 27 return sorted([p.name() for p in _DiscoverProfilers() 28 if p.is_supported(browser_type='any')]) 29