public LoadGenerator( int threadCount, TimeSpan duration, Uri uri, int numOfMeasuredThreads, int metricsCollectionCapacity) { _duration = duration; _tcpWorkerHelper = new TcpWorkerHelper(uri); _signals = Enumerable.Range(0, threadCount).Select(i => new ManualResetEvent(false)).ToList(); _threads = Enumerable.Range(0, threadCount).Select(i => { var method = i < numOfMeasuredThreads ? new ParameterizedThreadStart(Work_WithMetrics) : new ParameterizedThreadStart(Work_WithoutMetrics); return(new Thread(method) { IsBackground = true }); }).ToList(); var maxMeasuredThread = _threads.Count < numOfMeasuredThreads? _threads.Last() : _threads[numOfMeasuredThreads - 1]; _metrics = new GlobalMetrics( _threads.Max(t => t.ManagedThreadId), maxMeasuredThread.ManagedThreadId, new SysPerfLogger(duration), metricsCollectionCapacity); }
//private async Task GetApiKeys(string password) //{ // //mIWrBwmCu+/ZvZfwS2//R5YKYokBuIo7BRixpa1dpzY9EY6nV/7FMbR8aVC7D5okOU38a2QPYxLxK/Qsf6DqplVbU2irUtYEcBuxJt9wymu8KqiQLQIkd+lHUTxJxzmEGKnmI9JcVscWF5mkj9XANx5263PP7xh47d4NbDOSwn8Jud85ZZtvlWroemb9U2JI2uf/5I2hzhX7Op/shEVFDQbnM9YkJ3coIGRJm+cD9x2h7cDjYnyR1dNr1fJwB6Dx // string decrypted = Symmetric.Decrypt<AesManaged>("mIWrBwmCu+/ZvZfwS2//R5YKYokBuIo7BRixpa1dpzY9EY6nV/7FMbR8aVC7D5okOU38a2QPYxLxK/Qsf6DqplVbU2irUtYEcBuxJt9wymu8KqiQLQIkd+lHUTxJxzmEGKnmI9JcVscWF5mkj9XANx5263PP7xh47d4NbDOSwn8Jud85ZZtvlWroemb9U2JI2uf/5I2hzhX7Op/shEVFDQbnM9YkJ3coIGRJm+cD9x2h7cDjYnyR1dNr1fJwB6Dx" // , password, "apikeystore"); // var account = new CloudStorageAccount( // new StorageCredentials("apikeystore", decrypted), true); // var tableClient = account.CreateCloudTableClient(); // var table = tableClient.GetTableReference("ApiKeys"); // TableQuery<ApiKeyEntity> query = new TableQuery<ApiKeyEntity>().Where( // TableQuery.CombineFilters(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Dev"), TableOperators.And // , TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, "d666bdc6d2d2643ea61a6d5df444f6ef84e084b269565a2b0b5bf805fe36702b"))); // var result = await table.ExecuteQuerySegmentedAsync<ApiKeyEntity>(query, new TableContinuationToken()); // if (result.Results.Count > 0) // { // apiKeyCMC = result.Results[0].ApiKey; // } // query = new TableQuery<ApiKeyEntity>().Where( // TableQuery.CombineFilters(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Dev"), TableOperators.And // , TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, "7f0889c0a7ec97519dff1cf6e1ed52a99422928f5412d53e01e5d546398da472"))); // result = await table.ExecuteQuerySegmentedAsync<ApiKeyEntity>(query, new TableContinuationToken()); // if (result.Results.Count > 0) // { // apiKeyNomics = result.Results[0].ApiKey; // } //} private void SetPropertiesFromCMCGlobalMetrics(GlobalMetrics globalMetrics) { TotalMarketCap = string.Format("{0:c}", globalMetrics.Data.Quote.Usd.TotalMarketCap); TotalVolume24H = string.Format("{0:n}", globalMetrics.Data.Quote.Usd.TotalVolume24H); TimeStamp = globalMetrics.Status.Timestamp.ToString(); BtcDominance = string.Format("{0:n}%", globalMetrics.Data.BtcDominance); EthDominance = string.Format("{0:n}%", globalMetrics.Data.EthDominance); }
private async Task Refresh() { IsBusy = true; if (string.IsNullOrEmpty(keyStore.CoinMarketCapApiKey) || string.IsNullOrEmpty(keyStore.NomicsApiKey)) { if (string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Password2)) { RawData = "Password not set."; } else { keyStore = new MongoAtlasStore(); keyStore.LogIn(Password, Password2); keyStore.GetApiKeys(); } } string cmcMarketCap = null; if (!string.IsNullOrEmpty(keyStore.CoinMarketCapApiKey)) { cmcMarketCap = await GlobalMetricsRequest.GetGlobalMetrics(this.cmcConn, keyStore.CoinMarketCapApiKey).ConfigureAwait(false); } string nomicsMarketCap = null; string nomicsGlobalVol = null; if (!string.IsNullOrEmpty(keyStore.NomicsApiKey)) { nomicsMarketCap = await MarketHistoryRequest.GetMarketCapHistory(this.nomicsConn, keyStore.NomicsApiKey).ConfigureAwait(false); nomicsGlobalVol = await MarketHistoryRequest.GetGlobalVolumeHistory(this.nomicsConn, keyStore.NomicsApiKey).ConfigureAwait(false); } if (!string.IsNullOrEmpty(cmcMarketCap)) { if (cmcMarketCap == "Unauthorized") { RawData = cmcMarketCap; } else { SetPropertiesFromCMCGlobalMetrics(GlobalMetrics.FromJson(cmcMarketCap)); } } if (!string.IsNullOrEmpty(nomicsMarketCap)) { if (nomicsMarketCap == "Unauthorized") { RawData = nomicsMarketCap; } else { SetPropertiesFromNomicsMarketCapHistory(MarketCapHistory.FromJson(nomicsMarketCap)); } } if (!string.IsNullOrEmpty(nomicsGlobalVol)) { if (nomicsGlobalVol == "Unauthorized") { RawData = nomicsGlobalVol; } else { SetPropertiesFromNomicsMarketVolHistory(GlobalVolHistory.FromJson(nomicsGlobalVol)); } } IsBusy = false; }