public void OnDrag(PointerEventData eventData) { if (!this.disable && (this.mTouchID == eventData.pointerId)) { if (!this.touchdown) { this.child.gameObject.SetActive(true); Vector3 pos = this.GetPos((Vector3)eventData.get_position()); this.touchdownpos = pos; this.touchdown = true; this.child.localPosition = pos; this.Origin = pos; ProfilerHelper.BeginSample("Circle drag 1", Array.Empty <object>()); this.DealDrag(this.Origin, true); if (On_JoyTouchStart != null) { On_JoyTouchStart(this.m_Data); } ProfilerHelper.EndSample(); } this.bDrag = true; ProfilerHelper.BeginSample("Circle drag 2", Array.Empty <object>()); this.DealDrag(this.GetPos((Vector3)eventData.get_position()), true); if (On_JoyTouching != null) { On_JoyTouching(this.m_Data); } ProfilerHelper.EndSample(); } }
public TimeSpan GetElapsedTimeTest() { var start = Stopwatch.GetTimestamp(); DoWork(); return(ProfilerHelper.GetElapsedTime(start)); }
public Process StartDotnetTestSample(int traceAgentPort, string arguments, string packageVersion, int aspNetCorePort, int?statsdPort = null, string framework = "") { // get path to sample app that the profiler will attach to string sampleAppPath = EnvironmentHelper.GetTestCommandForSampleApplicationPath(packageVersion, framework); if (!File.Exists(sampleAppPath)) { throw new Exception($"application not found: {sampleAppPath}"); } // get full paths to integration definitions IEnumerable <string> integrationPaths = Directory.EnumerateFiles(".", "*integrations.json").Select(Path.GetFullPath); Output.WriteLine($"Starting Application: {sampleAppPath}"); string testCli = EnvironmentHelper.GetDotNetTest(); string exec = testCli; string appPath = testCli.StartsWith("dotnet") ? $"vstest {sampleAppPath}" : sampleAppPath; Output.WriteLine("Executable: " + exec); Output.WriteLine("ApplicationPath: " + appPath); return(ProfilerHelper.StartProcessWithProfiler( exec, appPath, EnvironmentHelper, integrationPaths, arguments, traceAgentPort: traceAgentPort, statsdPort: statsdPort, aspNetCorePort: aspNetCorePort, forceExecutable: true)); }
public Process StartSample(int traceAgentPort, string arguments = null) { // get path to native profiler dll string profilerDllPath = GetProfilerDllPath(); if (!File.Exists(profilerDllPath)) { throw new Exception($"profiler not found: {profilerDllPath}"); } // get path to sample app that the profiler will attach to string sampleAppPath = GetSampleApplicationPath(); if (!File.Exists(sampleAppPath)) { throw new Exception($"application not found: {sampleAppPath}"); } // get full paths to integration definitions IEnumerable <string> integrationPaths = Directory.EnumerateFiles(".", "*integrations.json").Select(Path.GetFullPath); return(ProfilerHelper.StartProcessWithProfiler( sampleAppPath, BuildParameters.CoreClr, integrationPaths, Instrumentation.ProfilerClsid, profilerDllPath, arguments, traceAgentPort: traceAgentPort)); }
public static void End() { ClientLogger.Error("end"); ProfilerHelper._newStats = ProfilerHelper.Capture(); ClientLogger.Error("old:" + ProfilerHelper._oldStats.ToString()); ClientLogger.Error("new:" + ProfilerHelper._newStats.ToString()); ClientLogger.Error("diff:" + (ProfilerHelper._newStats - ProfilerHelper._oldStats).ToString()); }
private void profile(string[] param) { Cheat._profileBegin = !Cheat._profileBegin; if (Cheat._profileBegin) { ProfilerHelper.Begin(); } else { ProfilerHelper.End(); } }
private void OnGUI() { if (GUILayout.Button("profiler", new GUILayoutOption[0])) { this._begin = !this._begin; if (this._begin) { ProfilerHelper.Begin(); } else { ProfilerHelper.End(); } } }
public Process StartSample(int traceAgentPort, string arguments = null) { // get path to sample app that the profiler will attach to string sampleAppPath = GetSampleApplicationPath(); if (!File.Exists(sampleAppPath)) { throw new Exception($"application not found: {sampleAppPath}"); } // get full paths to integration definitions IEnumerable <string> integrationPaths = Directory.EnumerateFiles(".", "*integrations.json").Select(Path.GetFullPath); return(ProfilerHelper.StartProcessWithProfiler( _environmentHelper, integrationPaths, arguments, traceAgentPort: traceAgentPort)); }
public Process StartSample(int traceAgentPort, string arguments, string packageVersion, int aspNetCorePort, string framework = "") { // get path to sample app that the profiler will attach to string sampleAppPath = EnvironmentHelper.GetSampleApplicationPath(packageVersion, framework); if (!File.Exists(sampleAppPath)) { throw new Exception($"application not found: {sampleAppPath}"); } // get full paths to integration definitions IEnumerable <string> integrationPaths = Directory.EnumerateFiles(".", "*integrations.json").Select(Path.GetFullPath); Output.WriteLine($"Starting Application: {sampleAppPath}"); return(ProfilerHelper.StartProcessWithProfiler( EnvironmentHelper.GetSampleExecutionSource(), sampleAppPath, EnvironmentHelper, integrationPaths, arguments, traceAgentPort: traceAgentPort, aspNetCorePort: aspNetCorePort)); }
public Process StartIISExpress(int traceAgentPort, int iisPort) { // get full paths to integration definitions IEnumerable <string> integrationPaths = Directory.EnumerateFiles(".", "*integrations.json").Select(Path.GetFullPath); var exe = EnvironmentHelper.GetSampleExecutionSource(); var args = new string[] { $"/clr:v4.0", $"/path:{EnvironmentHelper.GetSampleProjectDirectory()}", $"/systray:false", $"/port:{iisPort}", $"/trace:info", }; Output.WriteLine($"[webserver] starting {exe} {string.Join(" ", args)}"); var process = ProfilerHelper.StartProcessWithProfiler( EnvironmentHelper, integrationPaths, arguments: string.Join(" ", args), redirectStandardInput: true, traceAgentPort: traceAgentPort); var wh = new EventWaitHandle(false, EventResetMode.AutoReset); Task.Run(() => { string line; while ((line = process.StandardOutput.ReadLine()) != null) { Output.WriteLine($"[webserver][stdout] {line}"); if (line.Contains("IIS Express is running")) { wh.Set(); } } }); Task.Run(() => { string line; while ((line = process.StandardError.ReadLine()) != null) { Output.WriteLine($"[webserver][stderr] {line}"); } }); wh.WaitOne(5000); // Wait for iis express to finish starting up var retries = 5; while (true) { var usedPorts = IPGlobalProperties.GetIPGlobalProperties() .GetActiveTcpListeners() .Select(ipEndPoint => ipEndPoint.Port); if (usedPorts.Contains(iisPort)) { break; } retries--; if (retries == 0) { throw new Exception("Gave up waiting for IIS Express."); } Thread.Sleep(1500); } return(process); }
public (Process Process, string ConfigFile) StartIISExpress(int traceAgentPort, int iisPort, bool classicMode) { // get full paths to integration definitions IEnumerable <string> integrationPaths = Directory.EnumerateFiles(".", "*integrations.json").Select(Path.GetFullPath); var exe = EnvironmentHelper.GetSampleExecutionSource(); var configTemplate = File.ReadAllText("applicationHost.config"); var newConfig = Path.GetTempFileName(); configTemplate = configTemplate .Replace("[PATH]", EnvironmentHelper.GetSampleProjectDirectory()) .Replace("[PORT]", iisPort.ToString()) .Replace("[POOL]", classicMode ? "Clr4ClassicAppPool" : "Clr4IntegratedAppPool"); File.WriteAllText(newConfig, configTemplate); var args = new[] { "/site:sample", $"/config:{newConfig}", "/systray:false", "/trace:info" }; Output.WriteLine($"[webserver] starting {exe} {string.Join(" ", args)}"); var process = ProfilerHelper.StartProcessWithProfiler( EnvironmentHelper.GetSampleExecutionSource(), EnvironmentHelper.GetSampleExecutionSource(), EnvironmentHelper, integrationPaths, arguments: string.Join(" ", args), redirectStandardInput: true, traceAgentPort: traceAgentPort); var wh = new EventWaitHandle(false, EventResetMode.AutoReset); Task.Run(() => { string line; while ((line = process.StandardOutput.ReadLine()) != null) { Output.WriteLine($"[webserver][stdout] {line}"); if (line.Contains("IIS Express is running")) { wh.Set(); } } }); Task.Run(() => { string line; while ((line = process.StandardError.ReadLine()) != null) { Output.WriteLine($"[webserver][stderr] {line}"); } }); wh.WaitOne(5000); // Wait for iis express to finish starting up var retries = 5; while (true) { var usedPorts = IPGlobalProperties.GetIPGlobalProperties() .GetActiveTcpListeners() .Select(ipEndPoint => ipEndPoint.Port); if (usedPorts.Contains(iisPort)) { break; } retries--; if (retries == 0) { throw new Exception("Gave up waiting for IIS Express."); } Thread.Sleep(1500); } return(process, newConfig); }
public IISExpress StartIISExpress(int traceAgentPort, int iisPort) { // get path to native profiler dll string profilerDllPath = GetProfilerDllPath(); if (!File.Exists(profilerDllPath)) { throw new Exception($"profiler not found: {profilerDllPath}"); } var sampleDir = Path.Combine( GetSolutionDirectory(), "samples", $"Samples.{SampleAppName}"); // get full paths to integration definitions IEnumerable <string> integrationPaths = Directory.EnumerateFiles(".", "*integrations.json").Select(Path.GetFullPath); var exe = $"C:\\Program Files{(Environment.Is64BitProcess ? string.Empty : " (x86)")}\\IIS Express\\iisexpress.exe"; var args = new string[] { $"/clr:v4.0", $"/path:{sampleDir}", $"/systray:false", $"/port:{iisPort}", $"/trace:info", }; Output.WriteLine($"[webserver] starting {exe} {string.Join(" ", args)}"); var process = ProfilerHelper.StartProcessWithProfiler( exe, BuildParameters.CoreClr, integrationPaths, Instrumentation.ProfilerClsid, profilerDllPath, arguments: string.Join(" ", args), redirectStandardInput: true, traceAgentPort: traceAgentPort); var wh = new EventWaitHandle(false, EventResetMode.AutoReset); Task.Run(() => { string line; while ((line = process.StandardOutput.ReadLine()) != null) { if (line.Contains("IIS Express is running")) { wh.Set(); } Output.WriteLine($"[webserver][stdout] {line}"); } }); Task.Run(() => { string line; while ((line = process.StandardError.ReadLine()) != null) { Output.WriteLine($"[webserver][stderr] {line}"); } }); wh.WaitOne(5000); return(new IISExpress(process)); }
private void StartSample( MockTracerAgent agent, string arguments, string packageVersion = "", string framework = "", string path = "/Home", bool enableSecurity = true, string externalRulesFile = null, int?traceRateLimit = null) { var sampleAppPath = EnvironmentHelper.GetSampleApplicationPath(packageVersion, framework); // get path to sample app that the profiler will attach to const int mstimeout = 15_000; if (!File.Exists(sampleAppPath)) { throw new Exception($"application not found: {sampleAppPath}"); } // EnvironmentHelper.DebugModeEnabled = true; Output.WriteLine($"Starting Application: {sampleAppPath}"); var executable = EnvironmentHelper.IsCoreClr() ? EnvironmentHelper.GetSampleExecutionSource() : sampleAppPath; var args = EnvironmentHelper.IsCoreClr() ? $"{sampleAppPath} {arguments ?? string.Empty}" : arguments; EnvironmentHelper.CustomEnvironmentVariables.Add("DD_APPSEC_TRACE_RATE_LIMIT", traceRateLimit?.ToString()); EnvironmentHelper.CustomEnvironmentVariables.Add("DD_APPSEC_WAF_TIMEOUT", 1_000_000.ToString()); int?aspNetCorePort = default; _process = ProfilerHelper.StartProcessWithProfiler( executable, EnvironmentHelper, agent, args, aspNetCorePort: 0, enableSecurity: enableSecurity, externalRulesFile: externalRulesFile); // then wait server ready var wh = new EventWaitHandle(false, EventResetMode.AutoReset); _process.OutputDataReceived += (sender, args) => { if (args.Data != null) { if (args.Data.Contains("Now listening on:")) { var splitIndex = args.Data.LastIndexOf(':'); aspNetCorePort = int.Parse(args.Data.Substring(splitIndex + 1)); wh.Set(); } Output.WriteLine($"[webserver][stdout] {args.Data}"); } }; _process.BeginOutputReadLine(); _process.ErrorDataReceived += (sender, args) => { if (args.Data != null) { Output.WriteLine($"[webserver][stderr] {args.Data}"); } }; _process.BeginErrorReadLine(); wh.WaitOne(mstimeout); if (!aspNetCorePort.HasValue) { _process.Kill(); throw new Exception("Unable to determine port application is listening on"); } _httpPort = aspNetCorePort.Value; }
public static void Begin() { ClientLogger.Error("begin"); ProfilerHelper._oldStats = ProfilerHelper.Capture(); }
private void Update() { ProfilerHelper.BeginSample("udpate1"); tcs = new TaskCompletionSource <bool>(); ProfilerHelper.EndSample(); }