From 6e42aec4f64cf356dde7bad9426e07e0ea5b58d5 Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Mon, 18 May 2015 11:31:20 -0700 Subject: [PATCH] Deprecate 'dart:profiler' and move functionality to 'dart:developer' R=sgjesse@google.com Review URL: https://codereview.chromium.org//1133713006 --- runtime/lib/developer_sources.gypi | 2 + runtime/lib/profiler.cc | 2 +- runtime/lib/profiler_sources.gypi | 13 -- runtime/vm/bootstrap.cc | 2 +- runtime/vm/bootstrap.h | 1 - runtime/vm/intrinsifier.cc | 6 +- runtime/vm/method_recognizer.cc | 2 +- runtime/vm/method_recognizer.h | 11 +- runtime/vm/object.cc | 20 +- runtime/vm/service.cc | 2 +- runtime/vm/symbols.h | 2 +- runtime/vm/vm.gypi | 45 ---- sdk/lib/developer/developer.dart | 4 + sdk/lib/developer/developer_sources.gypi | 1 + sdk/lib/developer/profiler.dart | 197 +++++++++++++++++ sdk/lib/profiler/profiler.dart | 202 +----------------- .../dart2js/incremental/compile_all.dart | 2 +- tests/lib/lib.status | 6 +- tests/lib/profiler/metrics_num_test.dart | 2 +- tests/lib/profiler/metrics_test.dart | 2 +- tests/lib/profiler/user_tags_test.dart | 2 +- 21 files changed, 243 insertions(+), 283 deletions(-) delete mode 100644 runtime/lib/profiler_sources.gypi create mode 100644 sdk/lib/developer/profiler.dart diff --git a/runtime/lib/developer_sources.gypi b/runtime/lib/developer_sources.gypi index 4bedb6797d7..4d4218c425e 100644 --- a/runtime/lib/developer_sources.gypi +++ b/runtime/lib/developer_sources.gypi @@ -8,6 +8,8 @@ 'sources': [ 'developer.cc', 'developer.dart', + 'profiler.cc', + 'profiler.dart', ], } diff --git a/runtime/lib/profiler.cc b/runtime/lib/profiler.cc index a7342502559..7959360dec4 100644 --- a/runtime/lib/profiler.cc +++ b/runtime/lib/profiler.cc @@ -15,7 +15,7 @@ namespace dart { DECLARE_FLAG(bool, trace_intrinsified_natives); -// dart:profiler. +// Native implementations of the profiler parts of the dart:developer library. DEFINE_NATIVE_ENTRY(UserTag_new, 2) { ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); diff --git a/runtime/lib/profiler_sources.gypi b/runtime/lib/profiler_sources.gypi deleted file mode 100644 index 4d5ee05cfdd..00000000000 --- a/runtime/lib/profiler_sources.gypi +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -# for details. All rights reserved. Use of this source code is governed by a -# BSD-style license that can be found in the LICENSE file. - -# Sources visible via dart:profiler library. - -{ - 'sources': [ - 'profiler.cc', - 'profiler.dart', - ], -} - diff --git a/runtime/vm/bootstrap.cc b/runtime/vm/bootstrap.cc index c76ea3ae04b..0d61bdc5801 100644 --- a/runtime/vm/bootstrap.cc +++ b/runtime/vm/bootstrap.cc @@ -70,7 +70,7 @@ static bootstrap_lib_props bootstrap_libraries[] = { INIT_LIBRARY(ObjectStore::kProfiler, profiler, Bootstrap::profiler_source_paths_, - Bootstrap::profiler_patch_paths_), + NULL), INIT_LIBRARY(ObjectStore::kTypedData, typed_data, Bootstrap::typed_data_source_paths_, diff --git a/runtime/vm/bootstrap.h b/runtime/vm/bootstrap.h index 76758b624b0..772ba1c02f6 100644 --- a/runtime/vm/bootstrap.h +++ b/runtime/vm/bootstrap.h @@ -44,7 +44,6 @@ class Bootstrap : public AllStatic { static const char* isolate_patch_paths_[]; static const char* math_patch_paths_[]; static const char* mirrors_patch_paths_[]; - static const char* profiler_patch_paths_[]; static const char* typed_data_patch_paths_[]; }; diff --git a/runtime/vm/intrinsifier.cc b/runtime/vm/intrinsifier.cc index 37ff3d75be8..71cf333c0ed 100644 --- a/runtime/vm/intrinsifier.cc +++ b/runtime/vm/intrinsifier.cc @@ -84,10 +84,10 @@ void Intrinsifier::InitializeState() { TYPED_DATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION); GRAPH_TYPED_DATA_INTRINSICS_LIST(SETUP_FUNCTION); - // Setup all dart:profiler lib functions that can be intrinsified. - lib = Library::ProfilerLibrary(); + // Setup all dart:developer lib functions that can be intrinsified. + lib = Library::DeveloperLibrary(); ASSERT(!lib.IsNull()); - PROFILER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); + DEVELOPER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); #undef SETUP_FUNCTION } diff --git a/runtime/vm/method_recognizer.cc b/runtime/vm/method_recognizer.cc index 1aff186e38f..d0b941e4af2 100644 --- a/runtime/vm/method_recognizer.cc +++ b/runtime/vm/method_recognizer.cc @@ -47,7 +47,7 @@ void MethodRecognizer::InitializeState() { libs.Add(&Library::ZoneHandle(Library::MathLibrary())); libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); libs.Add(&Library::ZoneHandle(Library::InternalLibrary())); - libs.Add(&Library::ZoneHandle(Library::ProfilerLibrary())); + libs.Add(&Library::ZoneHandle(Library::DeveloperLibrary())); Function& func = Function::Handle(); #define SET_RECOGNIZED_KIND(class_name, function_name, enum_name, fp) \ diff --git a/runtime/vm/method_recognizer.h b/runtime/vm/method_recognizer.h index c6ad791c0aa..be707e6684c 100644 --- a/runtime/vm/method_recognizer.h +++ b/runtime/vm/method_recognizer.h @@ -293,16 +293,17 @@ namespace dart { GRAPH_CORE_INTRINSICS_LIST(V) \ GRAPH_TYPED_DATA_INTRINSICS_LIST(V) \ -#define PROFILER_LIB_INTRINSIC_LIST(V) \ - V(_UserTag, makeCurrent, UserTag_makeCurrent, 370414636) \ - V(::, _getDefaultTag, UserTag_defaultTag, 1159885970) \ - V(::, _getCurrentTag, Profiler_getCurrentTag, 1182126114) \ +#define DEVELOPER_LIB_INTRINSIC_LIST(V) \ + V(_UserTag, makeCurrent, UserTag_makeCurrent, 788201614) \ + V(::, _getDefaultTag, UserTag_defaultTag, 1080704381) \ + V(::, _getCurrentTag, Profiler_getCurrentTag, 2048029229) \ #define ALL_INTRINSICS_NO_INTEGER_LIB_LIST(V) \ CORE_LIB_INTRINSIC_LIST(V) \ + DEVELOPER_LIB_INTRINSIC_LIST(V) \ MATH_LIB_INTRINSIC_LIST(V) \ TYPED_DATA_LIB_INTRINSIC_LIST(V) \ - PROFILER_LIB_INTRINSIC_LIST(V) + #define ALL_INTRINSICS_LIST(V) \ ALL_INTRINSICS_NO_INTEGER_LIB_LIST(V) \ diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 3d282a804b9..56d210d0db8 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -1223,19 +1223,19 @@ RawError* Object::Init(Isolate* isolate) { RegisterPrivateClass(cls, Symbols::_LinkedHashMap(), lib); pending_classes.Add(cls); - // Pre-register the profiler library so we can place the vm class + // Pre-register the developer library so we can place the vm class // UserTag there rather than the core library. - lib = Library::LookupLibrary(Symbols::DartProfiler()); + lib = Library::LookupLibrary(Symbols::DartDeveloper()); if (lib.IsNull()) { - lib = Library::NewLibraryHelper(Symbols::DartProfiler(), true); + lib = Library::NewLibraryHelper(Symbols::DartDeveloper(), true); lib.SetLoadRequested(); lib.Register(); - object_store->set_bootstrap_library(ObjectStore::kProfiler, lib); + object_store->set_bootstrap_library(ObjectStore::kDeveloper, lib); } ASSERT(!lib.IsNull()); - ASSERT(lib.raw() == Library::ProfilerLibrary()); + ASSERT(lib.raw() == Library::DeveloperLibrary()); - lib = Library::LookupLibrary(Symbols::DartProfiler()); + lib = Library::LookupLibrary(Symbols::DartDeveloper()); ASSERT(!lib.IsNull()); cls = Class::New(); RegisterPrivateClass(cls, Symbols::_UserTag(), lib); @@ -10486,12 +10486,12 @@ void Library::CheckFunctionFingerprints() { POLYMORPHIC_TARGET_LIST(CHECK_FINGERPRINTS); all_libs.Clear(); - all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); - MATH_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); + all_libs.Add(&Library::ZoneHandle(Library::DeveloperLibrary())); + DEVELOPER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); all_libs.Clear(); - all_libs.Add(&Library::ZoneHandle(Library::ProfilerLibrary())); - PROFILER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); + all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); + MATH_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); all_libs.Clear(); all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index 074c1925d40..19cd84a357b 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -1874,7 +1874,7 @@ static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { static RawClass* GetMetricsClass(Isolate* isolate) { const Library& prof_lib = - Library::Handle(isolate, Library::ProfilerLibrary()); + Library::Handle(isolate, Library::DeveloperLibrary()); ASSERT(!prof_lib.IsNull()); const String& metrics_cls_name = String::Handle(isolate, String::New("Metrics")); diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h index d578e1f9e25..ee01b1b0dea 100644 --- a/runtime/vm/symbols.h +++ b/runtime/vm/symbols.h @@ -321,12 +321,12 @@ class ObjectPointerVisitor; V(DartNativeWrappersLibName, "dart.nativewrappers") \ V(DartCore, "dart:core") \ V(DartCollection, "dart:collection") \ + V(DartDeveloper, "dart:developer") \ V(DartInternal, "dart:_internal") \ V(DartIsolate, "dart:isolate") \ V(DartMirrors, "dart:mirrors") \ V(DartTypedData, "dart:typed_data") \ V(DartVMService, "dart:vmservice") \ - V(DartProfiler, "dart:profiler") \ V(DartIOLibName, "dart.io") \ V(EvalSourceUri, "evaluate:source") \ V(_Random, "_Random") \ diff --git a/runtime/vm/vm.gypi b/runtime/vm/vm.gypi index 211950f0dd6..e298592923c 100644 --- a/runtime/vm/vm.gypi +++ b/runtime/vm/vm.gypi @@ -26,7 +26,6 @@ 'mirrors_cc_file': '<(gen_source_dir)/mirrors_gen.cc', 'mirrors_patch_cc_file': '<(gen_source_dir)/mirrors_patch_gen.cc', 'profiler_cc_file': '<(gen_source_dir)/profiler_gen.cc', - 'profiler_patch_cc_file': '<(gen_source_dir)/profiler_patch_gen.cc', 'service_cc_file': '<(gen_source_dir)/service_gen.cc', 'snapshot_test_dat_file': '<(gen_source_dir)/snapshot_test.dat', 'snapshot_test_in_dat_file': 'snapshot_test_in.dat', @@ -196,7 +195,6 @@ 'generate_mirrors_cc_file#host', 'generate_mirrors_patch_cc_file#host', 'generate_profiler_cc_file#host', - 'generate_profiler_patch_cc_file#host', 'generate_typed_data_cc_file#host', 'generate_typed_data_patch_cc_file#host', ], @@ -209,7 +207,6 @@ '../lib/isolate_sources.gypi', '../lib/math_sources.gypi', '../lib/mirrors_sources.gypi', - '../lib/profiler_sources.gypi', '../lib/typed_data_sources.gypi', ], 'sources': [ @@ -234,7 +231,6 @@ '<(mirrors_cc_file)', '<(mirrors_patch_cc_file)', '<(profiler_cc_file)', - '<(profiler_patch_cc_file)', '<(typed_data_cc_file)', '<(typed_data_patch_cc_file)', ], @@ -255,7 +251,6 @@ '../lib/isolate_sources.gypi', '../lib/math_sources.gypi', '../lib/mirrors_sources.gypi', - '../lib/profiler_sources.gypi', '../lib/typed_data_sources.gypi', ], 'sources': [ @@ -1024,46 +1019,6 @@ }, ] }, - { - 'target_name': 'generate_profiler_patch_cc_file', - 'type': 'none', - 'toolsets':['host'], - 'includes': [ - # Load the runtime implementation sources. - '../lib/profiler_sources.gypi', - ], - 'sources/': [ - # Exclude all .[cc|h] files. - # This is only here for reference. Excludes happen after - # variable expansion, so the script has to do its own - # exclude processing of the sources being passed. - ['exclude', '\\.cc|h$'], - ], - 'actions': [ - { - 'action_name': 'generate_profiler_patch_cc', - 'inputs': [ - '../tools/gen_library_src_paths.py', - '<(libgen_in_cc_file)', - '<@(_sources)', - ], - 'outputs': [ - '<(profiler_patch_cc_file)', - ], - 'action': [ - 'python', - 'tools/gen_library_src_paths.py', - '--output', '<(profiler_patch_cc_file)', - '--input_cc', '<(libgen_in_cc_file)', - '--include', 'vm/bootstrap.h', - '--var_name', 'dart::Bootstrap::profiler_patch_paths_', - '--library_name', 'dart:profiler', - '<@(_sources)', - ], - 'message': 'Generating ''<(profiler_patch_cc_file)'' file.' - }, - ] - }, { 'target_name': 'generate_developer_cc_file', 'type': 'none', diff --git a/sdk/lib/developer/developer.dart b/sdk/lib/developer/developer.dart index db56aec4076..4df565e4222 100644 --- a/sdk/lib/developer/developer.dart +++ b/sdk/lib/developer/developer.dart @@ -11,6 +11,10 @@ /// library dart.developer; +import 'dart:convert'; + +part 'profiler.dart'; + /// If [when] is true, stop the program as if a breakpoint where hit at the /// following statement. Returns the value of [when]. Some debuggers may /// display [msg]. diff --git a/sdk/lib/developer/developer_sources.gypi b/sdk/lib/developer/developer_sources.gypi index fa6a87c9243..adbaea9f249 100644 --- a/sdk/lib/developer/developer_sources.gypi +++ b/sdk/lib/developer/developer_sources.gypi @@ -5,6 +5,7 @@ { 'sources': [ 'developer.dart', + 'profiler.dart', # The above file needs to be first if additional parts are added to the lib. ], } diff --git a/sdk/lib/developer/profiler.dart b/sdk/lib/developer/profiler.dart new file mode 100644 index 00000000000..566d0158318 --- /dev/null +++ b/sdk/lib/developer/profiler.dart @@ -0,0 +1,197 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +part of dart.developer; + +/// A UserTag can be used to group samples in the Observatory profiler. +abstract class UserTag { + /// The maximum number of UserTag instances that can be created by a program. + static const MAX_USER_TAGS = 64; + + factory UserTag(String label) => new _FakeUserTag(label); + + /// Label of [this]. + String get label; + + /// Make [this] the current tag for the isolate. Returns the current tag + /// before setting. + UserTag makeCurrent(); + + /// The default [UserTag] with label 'Default'. + static UserTag get defaultTag => _FakeUserTag._defaultTag; +} + +// This is a fake implementation of UserTag so that code can compile and run +// in dart2js. +class _FakeUserTag implements UserTag { + static Map _instances = {}; + + _FakeUserTag.real(this.label); + + factory _FakeUserTag(String label) { + // Canonicalize by name. + var existingTag = _instances[label]; + if (existingTag != null) { + return existingTag; + } + // Throw an exception if we've reached the maximum number of user tags. + if (_instances.length == UserTag.MAX_USER_TAGS) { + throw new UnsupportedError( + 'UserTag instance limit (${UserTag.MAX_USER_TAGS}) reached.'); + } + // Create a new instance and add it to the instance map. + var instance = new _FakeUserTag.real(label); + _instances[label] = instance; + return instance; + } + + final String label; + + UserTag makeCurrent() { + var old = _currentTag; + _currentTag = this; + return old; + } + + static final UserTag _defaultTag = new _FakeUserTag('Default'); +} + +var _currentTag = _FakeUserTag._defaultTag; + +/// Returns the current [UserTag] for the isolate. +UserTag getCurrentTag() { + return _currentTag; +} + +/// Abstract [Metric] class. Metric names must be unique, are hierarchical, +/// and use periods as separators. For example, 'a.b.c'. Uniqueness is only +/// enforced when a Metric is registered. The name of a metric cannot contain +/// the slash ('/') character. +abstract class Metric { + /// [name] of this metric. + final String name; + /// [description] of this metric. + final String description; + + Metric(this.name, this.description) { + if ((name == 'vm') || name.contains('/')) { + throw new ArgumentError('Invalid Metric name.'); + } + + } + + Map _toJSON(); +} + +/// A measured value with a min and max. Initial value is min. Value will +/// be clamped to the interval [min, max]. +class Gauge extends Metric { + final double min; + final double max; + + double _value; + double get value => _value; + set value(double v) { + if (v < min) { + v = min; + } else if (v > max) { + v = max; + } + _value = v; + } + + Gauge(String name, String description, this.min, this.max) + : super(name, description) { + if (min is! double) { + throw new ArgumentError('min must be a double'); + } + if (max is! double) { + throw new ArgumentError('max must be a double'); + } + if (!(min < max)) { + throw new ArgumentError('min must be less than max'); + } + _value = min; + } + + Map _toJSON() { + var map = { + 'type': 'Gauge', + 'id': 'metrics/$name', + 'name': name, + 'description': description, + 'value': value, + 'min': min, + 'max': max, + }; + return map; + } +} + + +/// A changing value. Initial value is 0.0. +class Counter extends Metric { + Counter(String name, String description) + : super(name, description); + + double _value = 0.0; + double get value => _value; + set value(double v) { + _value = v; + } + + Map _toJSON() { + var map = { + 'type': 'Counter', + 'id': 'metrics/$name', + 'name': name, + 'description': description, + 'value': value, + }; + return map; + } +} + +class Metrics { + static final Map _metrics = new Map(); + + /// Register [Metric]s to make them visible to Observatory. + static void register(Metric metric) { + if (metric is! Metric) { + throw new ArgumentError('metric must be a Metric'); + } + if (_metrics[metric.name] != null) { + throw new ArgumentError('Registered metrics have unique names'); + } + _metrics[metric.name] = metric; + } + + /// Deregister [Metric]s to make them not visible to Observatory. + static void deregister(Metric metric) { + if (metric is! Metric) { + throw new ArgumentError('metric must be a Metric'); + } + _metrics.remove(metric.name); + } + + static String _printMetric(String id) { + var metric = _metrics[id]; + if (metric == null) { + return null; + } + return JSON.encode(metric._toJSON()); + } + + static String _printMetrics() { + var metrics = []; + for (var metric in _metrics.values) { + metrics.add(metric._toJSON()); + } + var map = { + 'type': 'MetricList', + 'metrics': metrics, + }; + return JSON.encode(map); + } +} diff --git a/sdk/lib/profiler/profiler.dart b/sdk/lib/profiler/profiler.dart index 470638b23ff..84add7b10d4 100644 --- a/sdk/lib/profiler/profiler.dart +++ b/sdk/lib/profiler/profiler.dart @@ -2,199 +2,13 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/// Instrument your code with counters, gauges, and more. +/// Please see 'dart:developer'. +@Deprecated("Dart SDK 1.12") library dart.profiler; -import 'dart:convert'; - -/// A UserTag can be used to group samples in the Observatory profiler. -abstract class UserTag { - /// The maximum number of UserTag instances that can be created by a program. - static const MAX_USER_TAGS = 64; - - factory UserTag(String label) => new _FakeUserTag(label); - - /// Label of [this]. - String get label; - - /// Make [this] the current tag for the isolate. Returns the current tag - /// before setting. - UserTag makeCurrent(); - - /// The default [UserTag] with label 'Default'. - static UserTag get defaultTag => _FakeUserTag._defaultTag; -} - -// This is a fake implementation of UserTag so that code can compile and run -// in dart2js. -class _FakeUserTag implements UserTag { - static Map _instances = {}; - - _FakeUserTag.real(this.label); - - factory _FakeUserTag(String label) { - // Canonicalize by name. - var existingTag = _instances[label]; - if (existingTag != null) { - return existingTag; - } - // Throw an exception if we've reached the maximum number of user tags. - if (_instances.length == UserTag.MAX_USER_TAGS) { - throw new UnsupportedError( - 'UserTag instance limit (${UserTag.MAX_USER_TAGS}) reached.'); - } - // Create a new instance and add it to the instance map. - var instance = new _FakeUserTag.real(label); - _instances[label] = instance; - return instance; - } - - final String label; - - UserTag makeCurrent() { - var old = _currentTag; - _currentTag = this; - return old; - } - - static final UserTag _defaultTag = new _FakeUserTag('Default'); -} - -var _currentTag = _FakeUserTag._defaultTag; - -/// Returns the current [UserTag] for the isolate. -UserTag getCurrentTag() { - return _currentTag; -} - -/// Abstract [Metric] class. Metric names must be unique, are hierarchical, -/// and use periods as separators. For example, 'a.b.c'. Uniqueness is only -/// enforced when a Metric is registered. The name of a metric cannot contain -/// the slash ('/') character. -abstract class Metric { - /// [name] of this metric. - final String name; - /// [description] of this metric. - final String description; - - Metric(this.name, this.description) { - if ((name == 'vm') || name.contains('/')) { - throw new ArgumentError('Invalid Metric name.'); - } - - } - - Map _toJSON(); -} - -/// A measured value with a min and max. Initial value is min. Value will -/// be clamped to the interval [min, max]. -class Gauge extends Metric { - final double min; - final double max; - - double _value; - double get value => _value; - set value(double v) { - if (v < min) { - v = min; - } else if (v > max) { - v = max; - } - _value = v; - } - - Gauge(String name, String description, this.min, this.max) - : super(name, description) { - if (min is! double) { - throw new ArgumentError('min must be a double'); - } - if (max is! double) { - throw new ArgumentError('max must be a double'); - } - if (!(min < max)) { - throw new ArgumentError('min must be less than max'); - } - _value = min; - } - - Map _toJSON() { - var map = { - 'type': 'Gauge', - 'id': 'metrics/$name', - 'name': name, - 'description': description, - 'value': value, - 'min': min, - 'max': max, - }; - return map; - } -} - - -/// A changing value. Initial value is 0.0. -class Counter extends Metric { - Counter(String name, String description) - : super(name, description); - - double _value = 0.0; - double get value => _value; - set value(double v) { - _value = v; - } - - Map _toJSON() { - var map = { - 'type': 'Counter', - 'id': 'metrics/$name', - 'name': name, - 'description': description, - 'value': value, - }; - return map; - } -} - -class Metrics { - static final Map _metrics = new Map(); - - /// Register [Metric]s to make them visible to Observatory. - static void register(Metric metric) { - if (metric is! Metric) { - throw new ArgumentError('metric must be a Metric'); - } - if (_metrics[metric.name] != null) { - throw new ArgumentError('Registered metrics have unique names'); - } - _metrics[metric.name] = metric; - } - - /// Deregister [Metric]s to make them not visible to Observatory. - static void deregister(Metric metric) { - if (metric is! Metric) { - throw new ArgumentError('metric must be a Metric'); - } - _metrics.remove(metric.name); - } - - static String _printMetric(String id) { - var metric = _metrics[id]; - if (metric == null) { - return null; - } - return JSON.encode(metric._toJSON()); - } - - static String _printMetrics() { - var metrics = []; - for (var metric in _metrics.values) { - metrics.add(metric._toJSON()); - } - var map = { - 'type': 'MetricList', - 'metrics': metrics, - }; - return JSON.encode(map); - } -} +export 'dart:developer' show getCurrentTag, + Counter, + Gauge, + Metric, + Metrics, + UserTag; diff --git a/tests/compiler/dart2js/incremental/compile_all.dart b/tests/compiler/dart2js/incremental/compile_all.dart index 0c356410705..c2c7a9ede26 100644 --- a/tests/compiler/dart2js/incremental/compile_all.dart +++ b/tests/compiler/dart2js/incremental/compile_all.dart @@ -9,7 +9,7 @@ import 'dart:async'; import 'dart:io'; -import 'dart:profiler' show +import 'dart:developer' show UserTag; import 'package:dart2js_incremental/dart2js_incremental.dart' show diff --git a/tests/lib/lib.status b/tests/lib/lib.status index 5ff1e3c51d9..77d3d9a03f2 100644 --- a/tests/lib/lib.status +++ b/tests/lib/lib.status @@ -282,8 +282,8 @@ mirrors/deferred_type_test: StaticWarning, OK # Deliberately referes to a deferr mirrors/deferred_mirrors_metadata_test: Fail # Issue 17522 -profiler/metrics_test: Fail # Issue 20309 -profiler/metrics_num_test: Fail # Issue 20309 +developer/metrics_test: Fail # Issue 20309 +developer/metrics_num_test: Fail # Issue 20309 async/future_test: StaticWarning, OK # Deliberately broken implementation. @@ -305,7 +305,7 @@ convert/utf85_test: Skip # Pass, Slow Issue 12644. mirrors/mirrors_reader_test: Pass, Slow [ $compiler == dart2js ] -profiler/metrics_num_test: Skip # Because of a int / double type test. +developer/metrics_num_test: Skip # Because of a int / double type test. [ $arch == simarm64 ] convert/utf85_test: Skip # Pass, Slow Issue 20111. diff --git a/tests/lib/profiler/metrics_num_test.dart b/tests/lib/profiler/metrics_num_test.dart index d6a6689809a..bdb5291c248 100644 --- a/tests/lib/profiler/metrics_num_test.dart +++ b/tests/lib/profiler/metrics_num_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. // -import 'dart:profiler'; +import 'dart:developer'; import 'package:expect/expect.dart'; testGaugeDouble() { diff --git a/tests/lib/profiler/metrics_test.dart b/tests/lib/profiler/metrics_test.dart index 4dbf642320c..4e252ad433d 100644 --- a/tests/lib/profiler/metrics_test.dart +++ b/tests/lib/profiler/metrics_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. // -import 'dart:profiler'; +import 'dart:developer'; import 'package:expect/expect.dart'; testGauge1() { diff --git a/tests/lib/profiler/user_tags_test.dart b/tests/lib/profiler/user_tags_test.dart index f09abcdd2ac..f4fc4743a83 100644 --- a/tests/lib/profiler/user_tags_test.dart +++ b/tests/lib/profiler/user_tags_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. // -import 'dart:profiler'; +import 'dart:developer'; import 'package:expect/expect.dart'; // Test that the default tag is set.