提交Unity 联机Pro

This commit is contained in:
PC-20230316NUNE\Administrator
2024-08-17 14:27:18 +08:00
parent f00193b000
commit 894100ae37
7448 changed files with 854473 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using BestHTTP.Core;
namespace BestHTTP.Timings
{
public sealed class TimingCollector
{
public HTTPRequest ParentRequest { get; }
/// <summary>
/// When the TimingCollector instance created.
/// </summary>
public DateTime Start { get; private set; }
/// <summary>
/// List of added events.
/// </summary>
public List<TimingEvent> Events { get; private set; }
public TimingCollector(HTTPRequest parentRequest)
{
this.ParentRequest = parentRequest;
this.Start = DateTime.Now;
}
internal void AddEvent(string name, DateTime when, TimeSpan duration)
{
if (this.Events == null)
this.Events = new List<TimingEvent>();
if (duration == TimeSpan.Zero)
{
DateTime prevEventAt = this.Start;
if (this.Events.Count > 0)
prevEventAt = this.Events[this.Events.Count - 1].When;
duration = when - prevEventAt;
}
this.Events.Add(new TimingEvent(name, when, duration));
}
/// <summary>
/// Add an event. Duration is calculated from the previous event or start of the collector.
/// </summary>
public void Add(string name)
{
RequestEventHelper.EnqueueRequestEvent(new RequestEventInfo(this.ParentRequest, name, DateTime.Now));
}
/// <summary>
/// Add an event with a known duration.
/// </summary>
public void Add(string name, TimeSpan duration)
{
RequestEventHelper.EnqueueRequestEvent(new RequestEventInfo(this.ParentRequest, name, duration));
}
public TimingEvent FindFirst(string name)
{
if (this.Events == null)
return TimingEvent.Empty;
for (int i = 0; i < this.Events.Count; ++i)
{
if (this.Events[i].Name == name)
return this.Events[i];
}
return TimingEvent.Empty;
}
public TimingEvent FindLast(string name)
{
if (this.Events == null)
return TimingEvent.Empty;
for (int i = this.Events.Count - 1; i >= 0; --i)
{
if (this.Events[i].Name == name)
return this.Events[i];
}
return TimingEvent.Empty;
}
public override string ToString()
{
string result = string.Format("[TimingCollector Start: '{0}' ", this.Start.ToLongTimeString());
if (this.Events != null)
foreach (var @event in this.Events)
result += '\n' + @event.ToString();
result += "]";
return result;
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 71a56816af23e59479967fd2aaf8d72c
timeCreated: 1596976592
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,82 @@
using System;
namespace BestHTTP.Timings
{
public struct TimingEvent : IEquatable<TimingEvent>
{
public static readonly TimingEvent Empty = new TimingEvent(null, TimeSpan.Zero);
/// <summary>
/// Name of the event
/// </summary>
public readonly string Name;
/// <summary>
/// Duration of the event.
/// </summary>
public readonly TimeSpan Duration;
/// <summary>
/// When the event occurred.
/// </summary>
public readonly DateTime When;
public TimingEvent(string name, TimeSpan duration)
{
this.Name = name;
this.Duration = duration;
this.When = DateTime.Now;
}
public TimingEvent(string name, DateTime when, TimeSpan duration)
{
this.Name = name;
this.When = when;
this.Duration = duration;
}
public TimeSpan CalculateDuration(TimingEvent @event)
{
if (this.When < @event.When)
return @event.When - this.When;
return this.When - @event.When;
}
public bool Equals(TimingEvent other)
{
return this.Name == other.Name &&
this.Duration == other.Duration &&
this.When == other.When;
}
public override bool Equals(object obj)
{
if (obj is TimingEvent)
return this.Equals((TimingEvent)obj);
return false;
}
public override int GetHashCode()
{
return (this.Name != null ? this.Name.GetHashCode() : 0) ^
this.Duration.GetHashCode() ^
this.When.GetHashCode();
}
public static bool operator ==(TimingEvent lhs, TimingEvent rhs)
{
return lhs.Equals(rhs);
}
public static bool operator !=(TimingEvent lhs, TimingEvent rhs)
{
return !lhs.Equals(rhs);
}
public override string ToString()
{
return string.Format("['{0}': {1}]", this.Name, this.Duration);
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: b504248fda665464b8acfee61f219501
timeCreated: 1596976592
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
namespace BestHTTP.Timings
{
public static class TimingEventNames
{
public const string Queued = "Queued";
public const string Queued_For_Redirection = "Queued for redirection";
public const string DNS_Lookup = "DNS Lookup";
public const string TCP_Connection = "TCP Connection";
public const string Proxy_Negotiation = "Proxy Negotiation";
public const string TLS_Negotiation = "TLS Negotiation";
public const string Request_Sent = "Request Sent";
public const string Waiting_TTFB = "Waiting (TTFB)";
public const string Headers = "Headers";
public const string Loading_From_Cache = "Loading from Cache";
public const string Writing_To_Cache = "Writing to Cache";
public const string Response_Received = "Response Received";
public const string Queued_For_Disptach = "Queued for Dispatch";
public const string Finished = "Finished in";
public const string Callback = "Callback";
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: e9f77b1a6417dfd4abbbeb4f35020146
timeCreated: 1596976592
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: