Skip to content

Commit e87e8ce

Browse files
committed
Merge package:timing into the tools monorepo
2 parents 5590447 + 088950c commit e87e8ce

File tree

14 files changed

+1018
-0
lines changed

14 files changed

+1018
-0
lines changed

pkgs/timing/.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Dependabot configuration file.
2+
# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates
3+
version: 2
4+
5+
updates:
6+
- package-ecosystem: github-actions
7+
directory: /
8+
schedule:
9+
interval: monthly
10+
labels:
11+
- autosubmit
12+
groups:
13+
github-actions:
14+
patterns:
15+
- "*"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# A CI configuration to auto-publish pub packages.
2+
3+
name: Publish
4+
5+
on:
6+
pull_request:
7+
branches: [ master ]
8+
push:
9+
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
10+
11+
jobs:
12+
publish:
13+
if: ${{ github.repository_owner == 'dart-lang' }}
14+
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Dart CI
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
9+
schedule:
10+
- cron: "0 0 * * 0"
11+
12+
env:
13+
PUB_ENVIRONMENT: bot.github
14+
15+
jobs:
16+
# Check code formatting and static analysis on a single OS (linux)
17+
# against Dart dev.
18+
analyze:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
sdk: [3.4, dev]
24+
steps:
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
26+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
27+
with:
28+
sdk: ${{ matrix.sdk }}
29+
- id: install
30+
run: dart pub get
31+
- run: dart format --output=none --set-exit-if-changed .
32+
if: always() && steps.install.outcome == 'success'
33+
- run: dart analyze --fatal-infos
34+
if: always() && steps.install.outcome == 'success'
35+
36+
# Run tests on a matrix consisting of two dimensions:
37+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
38+
# 2. release channel: dev, 2.2.0
39+
test:
40+
needs: analyze
41+
runs-on: ${{ matrix.os }}
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
# Add macos-latest and/or windows-latest if relevant for this package.
46+
os: [ubuntu-latest]
47+
sdk: [3.4, dev]
48+
steps:
49+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
50+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
51+
with:
52+
sdk: ${{ matrix.sdk }}
53+
- id: install
54+
run: dart pub get
55+
- run: dart test --platform vm
56+
if: always() && steps.install.outcome == 'success'

pkgs/timing/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.packages
2+
/build/
3+
pubspec.lock
4+
5+
# Files generated by dart tools
6+
.dart_tool
7+
doc/

pkgs/timing/CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## 1.0.2-wip
2+
3+
- Require Dart `3.4`.
4+
5+
## 1.0.1
6+
7+
- Require Dart `2.14`.
8+
9+
## 1.0.0
10+
11+
- Enable null safety.
12+
- Require Dart `2.12`.
13+
14+
## 0.1.1+3
15+
16+
- Allow `package:json_annotation` `'>=1.0.0 <5.0.0'`.
17+
18+
## 0.1.1+2
19+
20+
- Support the latest version of `package:json_annotation`.
21+
- Require Dart 2.2 or later.
22+
23+
## 0.1.1+1
24+
25+
- Support the latest version of `package:json_annotation`.
26+
27+
## 0.1.1
28+
29+
- Add JSON serialization
30+
31+
## 0.1.0
32+
33+
- Initial release

pkgs/timing/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2018, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pkgs/timing/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[![Dart CI](https://github.com/dart-lang/timing/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/timing/actions/workflows/test-package.yml)
2+
[![pub package](https://img.shields.io/pub/v/timing.svg)](https://pub.dev/packages/timing)
3+
[![package publisher](https://img.shields.io/pub/publisher/timing.svg)](https://pub.dev/packages/timing/publisher)
4+
5+
Timing is a simple package for tracking performance of both async and sync actions
6+
7+
## Usage
8+
9+
```dart
10+
var tracker = AsyncTimeTracker();
11+
await tracker.track(() async {
12+
// some async code here
13+
});
14+
15+
// Use results
16+
print('${tracker.duration} ${tracker.innerDuration} ${tracker.slices}');
17+
```
18+
19+
## Building
20+
21+
Use the following command to re-generate `lib/src/timing.g.dart` file:
22+
23+
```bash
24+
dart pub run build_runner build
25+
```
26+
27+
## Publishing automation
28+
29+
For information about our publishing automation and release process, see
30+
https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

pkgs/timing/analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# https://dart.dev/tools/analysis#the-analysis-options-file
2+
include: package:dart_flutter_team_lints/analysis_options.yaml

pkgs/timing/lib/src/clock.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
/// A function that returns the current [DateTime].
8+
typedef _Clock = DateTime Function();
9+
DateTime _defaultClock() => DateTime.now();
10+
11+
const _zoneKey = #timing_Clock;
12+
13+
/// Returns the current [DateTime].
14+
///
15+
/// May be overridden for tests using [scopeClock].
16+
DateTime now() => (Zone.current[_zoneKey] as _Clock? ?? _defaultClock)();
17+
18+
/// Runs [f], with [clock] scoped whenever [now] is called.
19+
T scopeClock<T>(DateTime Function() clock, T Function() f) =>
20+
runZoned(f, zoneValues: {_zoneKey: clock});

0 commit comments

Comments
 (0)