| Index: third_party/grpc/src/csharp/Grpc.IntegrationTesting/WallClockStopwatch.cs
|
| diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs b/third_party/grpc/src/csharp/Grpc.IntegrationTesting/WallClockStopwatch.cs
|
| similarity index 61%
|
| copy from third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs
|
| copy to third_party/grpc/src/csharp/Grpc.IntegrationTesting/WallClockStopwatch.cs
|
| index e547d834986de8d80703504469e9c39b3d8ae93d..e44ae2a5ff364ad172b42cbc26372e342f2db4de 100644
|
| --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs
|
| +++ b/third_party/grpc/src/csharp/Grpc.IntegrationTesting/WallClockStopwatch.cs
|
| @@ -1,7 +1,7 @@
|
| #region Copyright notice and license
|
| -// Protocol Buffers - Google's data interchange format
|
| -// Copyright 2008 Google Inc. All rights reserved.
|
| -// https://developers.google.com/protocol-buffers/
|
| +
|
| +// Copyright 2015, Google Inc.
|
| +// All rights reserved.
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -28,41 +28,51 @@
|
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| +
|
| #endregion
|
|
|
| -namespace Google.Protobuf.Reflection
|
| +using System;
|
| +using System.Collections.Generic;
|
| +using System.Diagnostics;
|
| +using System.IO;
|
| +using System.Linq;
|
| +using System.Text.RegularExpressions;
|
| +using System.Threading;
|
| +using System.Threading.Tasks;
|
| +using Google.Protobuf;
|
| +using Grpc.Core;
|
| +using Grpc.Core.Utils;
|
| +using NUnit.Framework;
|
| +using Grpc.Testing;
|
| +
|
| +namespace Grpc.IntegrationTesting
|
| {
|
| /// <summary>
|
| - /// Represents a package in the symbol table. We use PackageDescriptors
|
| - /// just as placeholders so that someone cannot define, say, a message type
|
| - /// that has the same name as an existing package.
|
| + /// Snapshottable wall clock stopwatch.
|
| /// </summary>
|
| - internal sealed class PackageDescriptor : IDescriptor
|
| + public class WallClockStopwatch
|
| {
|
| - private readonly string name;
|
| - private readonly string fullName;
|
| - private readonly FileDescriptor file;
|
| -
|
| - internal PackageDescriptor(string name, string fullName, FileDescriptor file)
|
| - {
|
| - this.file = file;
|
| - this.fullName = fullName;
|
| - this.name = name;
|
| - }
|
| + long startTicks;
|
|
|
| - public string Name
|
| + public WallClockStopwatch()
|
| {
|
| - get { return name; }
|
| + this.startTicks = DateTime.UtcNow.Ticks;
|
| }
|
|
|
| - public string FullName
|
| + public TimeSpan GetElapsedSnapshot(bool reset)
|
| {
|
| - get { return fullName; }
|
| - }
|
| + var utcNow = DateTime.UtcNow;
|
|
|
| - public FileDescriptor File
|
| - {
|
| - get { return file; }
|
| + long oldStartTicks;
|
| + if (reset)
|
| + {
|
| + oldStartTicks = Interlocked.Exchange(ref this.startTicks, utcNow.Ticks);
|
| + }
|
| + else
|
| + {
|
| + oldStartTicks = this.startTicks;
|
| + }
|
| + return utcNow - new DateTime(oldStartTicks, DateTimeKind.Utc);
|
| }
|
| }
|
| -}
|
| +}
|
|
|