Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
561d17a8
Commit
561d17a8
authored
Jul 30, 2017
by
Devon Carew
Committed by
GitHub
Jul 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a profile() method (#11443)
* add a profile() method * add todos
parent
6655074b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
foundation.dart
packages/flutter/lib/foundation.dart
+1
-0
profile.dart
packages/flutter/lib/src/foundation/profile.dart
+18
-0
profile_test.dart
packages/flutter/test/foundation/profile_test.dart
+21
-0
No files found.
packages/flutter/lib/foundation.dart
View file @
561d17a8
...
@@ -42,6 +42,7 @@ export 'src/foundation/licenses.dart';
...
@@ -42,6 +42,7 @@ export 'src/foundation/licenses.dart';
export
'src/foundation/observer_list.dart'
;
export
'src/foundation/observer_list.dart'
;
export
'src/foundation/platform.dart'
;
export
'src/foundation/platform.dart'
;
export
'src/foundation/print.dart'
;
export
'src/foundation/print.dart'
;
export
'src/foundation/profile.dart'
;
export
'src/foundation/serialization.dart'
;
export
'src/foundation/serialization.dart'
;
export
'src/foundation/synchronous_future.dart'
;
export
'src/foundation/synchronous_future.dart'
;
export
'src/foundation/tree_diagnostics_mixin.dart'
;
export
'src/foundation/tree_diagnostics_mixin.dart'
;
packages/flutter/lib/src/foundation/profile.dart
0 → 100644
View file @
561d17a8
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
;
/// Whether we've been built in release mode.
const
bool
_kReleaseMode
=
const
bool
.
fromEnvironment
(
"dart.vm.product"
);
/// When running in profile mode (or debug mode), invoke the given function.
///
/// In release mode, the function is not invoked.
// TODO(devoncarew): Going forward, we'll want the call to profile() to be tree-shaken out.
void
profile
(
VoidCallback
function
)
{
if
(
_kReleaseMode
)
return
;
function
();
}
packages/flutter/test/foundation/profile_test.dart
0 → 100644
View file @
561d17a8
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:test/test.dart'
;
// We run our tests in debug mode, to this will always evaluate to false...
const
bool
isReleaseMode
=
const
bool
.
fromEnvironment
(
"dart.vm.product"
);
void
main
(
)
{
// TODO(devoncarew): This test - while very nice - isn't testing what we really want to know:
// that the code in the `profile` closure is omitted in release mode.
test
(
"profile invokes its closure in debug or profile mode"
,
()
{
int
count
=
0
;
profile
(()
{
count
++;
});
expect
(
count
,
isReleaseMode
?
0
:
1
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment