示例#1
0
        public ActionResult PegCpu()
        {
            var cpuLevel = ConfigurationHelper.GetConfigValue <double>("ErrorsPegCPULevel");
            var pegTime  = ConfigurationHelper.GetConfigValue <TimeSpan>("ErrorsPegCPUTimeSpan");

            Task.Run(() => { CpuHelper.PegCpu(cpuLevel, pegTime); });
            return(RedirectToAction("Index"));
        }
示例#2
0
        static TestResourcesAnalyzer()
        {
            _enabled = bool.TryParse(Environment.GetEnvironmentVariable("TEST_RESOURCE_ANALYZER_ENABLE"), out var value) && value;
            if (_enabled == false)
            {
                return;
            }

            _cpuUsageCalculator = CpuHelper.GetOSCpuUsageCalculator();
            _metricCacher       = new TestResourcesAnalyzerMetricCacher(_cpuUsageCalculator);
            _timer = new Timer(ProcessQueue, null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
        }
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return; //prevents other code from running before offing itself
        }

        DontDestroyOnLoad(gameObject);
    }
        public TestResourceSnapshotWriter(string filename = null)
        {
            lock (_syncObject)
            {
                _cpuUsageCalculator = CpuHelper.GetOSCpuUsageCalculator();
                _metricCacher       = new TestResourcesAnalyzerMetricCacher(_cpuUsageCalculator);

                filename ??= $"TestResources_{DateTime.UtcNow:dd_MM_yyyy_HH_mm_ss}.csv";

                var file = File.OpenWrite(filename);

                file.Position = 0;
                file.SetLength(0);

                _csvWriter = new CsvWriter(new StreamWriter(file), CultureInfo.InvariantCulture);
                _csvWriter.WriteHeader(typeof(TestResourceSnapshot));
            }
        }
示例#5
0
 public ActionResult UnpegCpu()
 {
     Task.Run(() => { CpuHelper.UnPegCpu(); });
     return(RedirectToAction("Index"));
 }
示例#6
0
        public static bool login(string username, string pwd)
        {
            string     posData    = "loginName=" + username + "&pwd=" + pwd + "&serno=" + CpuHelper.GetCPUSerialNumber();
            HttpResult httpResult = postData(Constants.serverUrl + "/all/terminal/login", posData);

            try
            {
                ServiceDataResult result = JSON.parse <ServiceDataResult>(httpResult.Html);
                if (result.code == "0")
                {
                    token = result.data;
                    prop.Add("username", username);
                    prop.Add("pwd", pwd);
                    prop.save("./data.db");
                    return(true);
                }
                else
                {
                    lastError = result.msg;
                    return(false);
                }
            }
            catch
            {
                Console.WriteLine(httpResult.Html);
                return(false);
            }
        }
示例#7
0
 private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
 {
     CpuCountLabel.Content = CpuHelper.GteCpuCount();
 }