Beispiel #1
0
 void PopulateLBs()
 {
     for (int i = 0; i < harvestStats.items.Count; i++)
     {
         if (!listBox1.Items.Contains(harvestStats.items[i].name))
         {
             listBox1.Items.Add(harvestStats.items[i].name);
         }
     }
     if (listBox1.SelectedIndex > -1)
     {
         NodeStats ns       = null;
         string    selected = (string)listBox1.Items[listBox1.SelectedIndex];
         for (int i = 0; i < harvestStats.items.Count; i++)
         {
             if (harvestStats.items[i].name == selected)
             {
                 ns = harvestStats.items[i];
                 break;
             }
         }
         for (int i = 0; i < harvestStats.items.Count; i++)
         {
             if (!listBox2.Items.Contains(ns.items[i].name))
             {
                 listBox2.Items.Add(ns.items[i].name);
             }
         }
     }
 }
Beispiel #2
0
        private NodeStats diameterOfBinaryTree(TreeNode node)
        {
            if (node.left == null && node.right == null)
            {
                return(new NodeStats {
                    Depth = 1, Diameter = 0
                });
            }
            NodeStats leftPath = new NodeStats(), rightPath = new NodeStats();

            if (node.left != null)
            {
                leftPath = diameterOfBinaryTree(node.left);
            }

            if (node.right != null)
            {
                rightPath = diameterOfBinaryTree(node.right);
            }

            NodeStats stats = new NodeStats();

            stats.Depth    = Math.Max(leftPath.Depth, rightPath.Depth) + 1;
            stats.Diameter = Math.Max(
                Math.Max(leftPath.Diameter, rightPath.Diameter),
                leftPath.Depth + rightPath.Depth);

            return(stats);
        }
        public void AddNew()
        {
            //Arrange
            AddNewCarRequest addNewCarRequest = new AddNewCarRequest("BMW", 1999);
            string           json             = JsonSerializer.Serialize(addNewCarRequest);
            StringContent    content          = new StringContent(json, Encoding.UTF8, "application/json");

            var step = HttpStep.Create("addNew", ctx =>
                                       Task.FromResult(Http.CreateRequest("POST", endpoint)
                                                       .WithBody(content)
                                                       ));

            var scenario = ScenarioBuilder.CreateScenario("Add", step)
                           .WithoutWarmUp()
                           .WithLoadSimulations(Simulation.KeepConstant(2, TimeSpan.FromSeconds(30)));

            //Act
            NodeStats nodeStats = NBomberRunner.RegisterScenarios(scenario).Run();

            //Assert
            nodeStats.OkCount.Should().Be(nodeStats.RequestCount);
            StepStats stepStats = nodeStats.ScenarioStats[0].StepStats[0];

            stepStats.RPS.Should().BeGreaterOrEqualTo(1500);
        }
        public ProvenBlockHeaderStoreTests() : base(new StratisTest())
        {
            var nodeStats = new NodeStats(DateTimeProvider.Default);

            this.provenBlockHeaderRepository = new ProvenBlockHeaderRepository(this.Network, CreateTestDir(this), this.LoggerFactory.Object);

            this.provenBlockHeaderStore = new ProvenBlockHeaderStore(DateTimeProvider.Default, this.LoggerFactory.Object, this.provenBlockHeaderRepository, nodeStats);
        }
 protected void Assert(NodeStats node)
 {
     node.Name.Should().NotBeNullOrWhiteSpace();
     node.Timestamp.Should().BeGreaterThan(0);
     node.TransportAddress.Should().NotBeNullOrWhiteSpace();
     node.Host.Should().NotBeNullOrWhiteSpace();
     node.Ip.Should().NotBeEmpty();
 }
Beispiel #6
0
        private void PopulateLV1()
        {
            listBox2.Items.Clear();
            listView1.Columns.Clear();
            listView1.Items.Clear();
            if (listBox1.SelectedIndex > -1)
            {
                NodeStats nS = null;
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                    if (harvestStats.items[i].name == (string)listBox1.Items[listBox1.SelectedIndex])
                    {
                        nS = harvestStats.items[i];
                    }
                }
                for (int i = 0; i < nS.items.Count; i++)
                {
                    listBox2.Items.Add(nS.items[i].name);
                }

                listView1.Columns.Clear();
                listView1.Items.Clear();
                listView1.Columns.Add("Type");
                listView1.Columns.Add("# Attempts");
                listView1.Columns.Add("% Attempts");
                listView1.Columns.Add("# Collects");
                listView1.Columns.Add("% Collects");
                listView1.Columns.Add("# Items");
                listView1.Columns.Add("% Items");
                listView1.Columns.Add("Avg Items/Collect");
                listView1.Columns.Add("# Rares");
                listView1.Columns.Add("% Rares");
                listView1.Columns.Add("# Bountiful");
                listView1.Columns.Add("% Bountiful");
                listView1.Columns.Add("# Bonus");
                nS.items.Sort();
                for (int i = 0; i < nS.items.Count; i++)
                {
                    ItemStats    iS  = nS.items[i];
                    ListViewItem lvi = new ListViewItem(iS.name);
                    lvi.SubItems.Add(iS.TotalAttempts.ToString());
                    lvi.SubItems.Add(String.Format("{0:0.00}%", iS.PercentAttempts));
                    lvi.SubItems.Add(iS.TotalCollects.ToString());
                    lvi.SubItems.Add(String.Format("{0:0.00}%", iS.PercentCollects));
                    lvi.SubItems.Add(iS.TotalItems.ToString());
                    lvi.SubItems.Add(String.Format("{0:0.00}%", iS.PercentItems));
                    lvi.SubItems.Add(String.Format("{0:0.00}", iS.AvgItemsPerCollect));
                    lvi.SubItems.Add(iS.TotalRares.ToString());
                    lvi.SubItems.Add(String.Format("{0:0.00}%", iS.PercentRares));
                    lvi.SubItems.Add(iS.TotalBountiful.ToString());
                    lvi.SubItems.Add(String.Format("{0:0.00}%", iS.PercentBountiful));
                    lvi.SubItems.Add(iS.TotalBonus.ToString());
                    listView1.Items.Add(lvi);
                }
                ResizeLVCols();
                label1.Text = String.Format("Data Selected: {0}", nS.name);
            }
        }
Beispiel #7
0
        public int DiameterOfBinaryTree(TreeNode root)
        {
            if (root == null)
            {
                return(0);
            }
            NodeStats stats = diameterOfBinaryTree(root);

            return(stats.Diameter);
        }
        private void AssertResults(NodeStats stats)
        {
            var scenarioStats = stats.ScenarioStats.First();

            scenarioStats.LatencyCount.Less800.Should().BeGreaterOrEqualTo(stats.RequestCount - 10);

            var stepStats = stats.ScenarioStats.First().StepStats.First();

            stepStats.FailCount.Should().Be(0);
            stepStats.RPS.Should().BeGreaterOrEqualTo(100);
        }
Beispiel #9
0
        public ProvenBlockHeaderStoreTests() : base(new StraxTest())
        {
            var nodeStats = new NodeStats(DateTimeProvider.Default, NodeSettings.Default(this.Network), new Mock <IVersionProvider>().Object);

            var dBreezeSerializer = new DBreezeSerializer(this.Network.Consensus.ConsensusFactory);

            var ibdMock = new Mock <IInitialBlockDownloadState>();

            ibdMock.Setup(s => s.IsInitialBlockDownload()).Returns(false);

            this.provenBlockHeaderRepository = new LevelDbProvenBlockHeaderRepository(this.Network, CreateTestDir(this), this.LoggerFactory.Object, dBreezeSerializer);
            this.provenBlockHeaderStore      = new ProvenBlockHeaderStore(DateTimeProvider.Default, this.LoggerFactory.Object, this.provenBlockHeaderRepository, nodeStats, ibdMock.Object);
        }
 public NodeStats(NodeStats copy)
 {
     CorruptingPower      = copy.CorruptingPower;
     CorruptionResistance = copy.CorruptionResistance;
     DamageResistance     = copy.DamageResistance;
     CorruptionHP         = copy.CorruptionHP;
     HP            = copy.HP;
     SpawnRate     = copy.SpawnRate;
     SpawnStrength = copy.SpawnStrength;
     AttackPower   = copy.AttackPower;
     AttackRate    = copy.AttackRate;
     AttackRange   = copy.AttackRange;
 }
Beispiel #11
0
        internal void Load(string filePath)
        {
            FilePath = filePath;
            var logName = Path.GetFileName(filePath);

            using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
                reader = new FastBinaryReader(stream);

                Version            = reader.ReadByte();
                profileCostPerCall = readVarInt() * 1E-12;

                using (new Timer("Parse plog: " + logName)) {
                    ParseLoop();
                }
            }

            ProcessNameIds();

            using (new Timer("ComputeTimes plog: " + logName)) {
#if true
                Parallel.ForEach(Frames, f => f.ComputeTime());
#else
                foreach (var f in Frames)
                {
                    f.ComputeTime();
                }
#endif
            }

            TotalNodes      = Frames.Sum(f => f.Calls.Length);
            NodeStats       = GetStatsForRange(0, Frames.Count);
            NodeStatsLookup = NodeStats.ToDictionary(n => n.Id, n => n);

            var sortedFrames = Frames.
                               OrderByDescending(f => f.MainThread.Time).
                               ToArray();
            var avgtime = sortedFrames.
                          Skip((int)(sortedFrames.Length * 0.1)).
                          Select(f => f.MainThread.TimeMs).
                          Average();
            // Treat any frame that is more than 80% slower than the average of 90 percentile frame time as a slow frame
            SlowFrameThreshold = avgtime * 1.8;

            SlowFrames = Frames.
                         Skip(2). // Skip the first two frames that could be the game still loading in or something
                         Where(f => f.MainThread.TimeMs > SlowFrameThreshold).
                         ToList();

            return;
        }
Beispiel #12
0
        private void PopulateLV2()
        {
            listView1.Columns.Clear();
            listView1.Items.Clear();
            if (listBox2.SelectedIndex > -1)
            {
                NodeStats nS = null;
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                    if (harvestStats.items[i].name == (string)listBox1.Items[listBox1.SelectedIndex])
                    {
                        nS = harvestStats.items[i];
                    }
                }
                ItemStats iS = null;
                for (int i = 0; i < listBox2.Items.Count; i++)
                {
                    if (nS.items[i].name == (string)listBox2.Items[listBox2.SelectedIndex])
                    {
                        iS = nS.items[i];
                    }
                }

                listView1.Columns.Clear();
                listView1.Items.Clear();
                listView1.Columns.Add("Time");
                listView1.Columns.Add("Action");
                listView1.Columns.Add("Amount");
                listView1.Columns.Add("Item Name");
                listView1.Columns.Add("Node Name");
                listView1.Columns.Add("Rare");
                listView1.Columns.Add("Bountiful");
                iS.items.Sort();
                for (int i = 0; i < iS.items.Count; i++)
                {
                    HarvestData  hD  = iS.items[i];
                    ListViewItem lvi = new ListViewItem(hD.time.ToLongTimeString());
                    lvi.SubItems.Add(hD.actionVerb);
                    lvi.SubItems.Add(hD.amount.ToString());
                    lvi.SubItems.Add(hD.itemName);
                    lvi.SubItems.Add(hD.nodeType);
                    lvi.SubItems.Add(hD.rare.ToString());
                    lvi.SubItems.Add(hD.bountiful.ToString());
                    listView1.Items.Add(lvi);
                }
                ResizeLVCols();
                label1.Text = String.Format("Data Selected: {0} - {1}", iS.parent.name, iS.name);
            }
        }
        public ProvenBlockHeaderStoreTests() : base(KnownNetworks.StratisTest)
        {
            this.consensusManager     = new Mock <IConsensusManager>();
            this.nodeLifetime         = new Mock <INodeLifetime>();
            this.nodeStats            = new NodeStats(DateTimeProvider.Default);
            this.asyncLoopFactoryLoop = new Mock <IAsyncLoopFactory>();

            this.Folder = CreateTestDir(this);

            this.provenBlockHeaderRepository = new ProvenBlockHeaderRepository(this.network, this.Folder, this.LoggerFactory.Object);

            this.provenBlockHeaderStore = new ProvenBlockHeaderStore(
                DateTimeProvider.Default, this.LoggerFactory.Object, this.provenBlockHeaderRepository,
                this.nodeLifetime.Object, this.nodeStats, this.asyncLoopFactoryLoop.Object);
        }
    public void FillNode(Node n, Vector2 position, bool Corrupt = false)
    {
        var base_stat_block = new NodeStats();

        base_stat_block.Init();
        n.BaseStats = base_stat_block;

        n.transform.position = new Vector3(position.x, position.y, n.transform.position.z);
        n.transform.parent   = NodeHolder;
        n.PowerUpSlots       = Random.Range(bp.NodeSlotsRange.x, bp.NodeSlotsRange.y);
        n.Energy             = Random.Range(bp.EnergyRange.x, bp.EnergyRange.y);

        if (Corrupt)
        {
            n.Free       = false;
            n.Corruption = n.BaseStats.CorruptionHP;
        }

        n.UpdateStats();
    }
Beispiel #15
0
    public void UpdateStats()
    {
        CurrentStats = new NodeStats(BaseStats);

        foreach (var item in EffectivePowerUps)
        {
            if (item != null)
            {
                if (OwnPowerUps.Contains(item))
                {
                    item.Apply(this);
                    item.Apply(this);
                    item.Apply(this);
                }
                else
                {
                    item.Apply(this);
                }
            }
        }
    }
    public void Init(NodeStats node_stats)
    {
        nc = NodeController.Instance;
        bp = BaseParameters.Instance;
        eh = EventHandler.Instance;

        float total       = nc.Nodes.Count;
        float free_cities = total - nc.CorruptNodes.Count;

        float scale    = 1 - (free_cities / total);
        float strength = node_stats.SpawnStrength * bp.SoldierBaseScaling * scale * (8 / (ActiveSoldiers.Count + 1));

        FireRate = BaseFireRate;
        Damage   = BaseDamage * strength;
        HP       = BaseHP * strength;

        ActiveSoldiers.Add(this);
        eh.Sub(Event.EventType.SoldierActTick, this);

        SetTarget();
    }
Beispiel #17
0
            public void AddHarvest(HarvestData item)
            {
                NodeStats all   = new NodeStats(" All", this);
                int       index = items.IndexOf(all);

                if (index > -1)
                {
                    all = items[index];
                }
                else
                {
                    items.Add(all);
                }
                NodeStats uniqueAction = new NodeStats(item.actionVerb, this);

                index = items.IndexOf(uniqueAction);
                if (index > -1)
                {
                    uniqueAction = items[index];
                }
                else
                {
                    items.Add(uniqueAction);
                }
                NodeStats uniqueNode = new NodeStats(item.nodeType, this);

                index = items.IndexOf(uniqueNode);
                if (index > -1)
                {
                    uniqueNode = items[index];
                }
                else
                {
                    items.Add(uniqueNode);
                }

                all.AddHarvest(item);
                uniqueAction.AddHarvest(item);
                uniqueNode.AddHarvest(item);
            }
Beispiel #18
0
 void PopulateLV0()
 {
     listBox1.SelectedIndex = -1;
     listBox2.Items.Clear();
     listView1.Columns.Clear();
     listView1.Items.Clear();
     listView1.Columns.Add("Type");
     listView1.Columns.Add("# Attempts");
     listView1.Columns.Add("% Attempts");
     listView1.Columns.Add("# Collects");
     listView1.Columns.Add("% Collects");
     listView1.Columns.Add("# Items");
     listView1.Columns.Add("% Items");
     listView1.Columns.Add("# Rares");
     listView1.Columns.Add("% Rares");
     listView1.Columns.Add("# Bountiful");
     listView1.Columns.Add("% Bountiful");
     listView1.Columns.Add("# Bonus");
     harvestStats.items.Sort();
     for (int i = 0; i < harvestStats.items.Count; i++)
     {
         NodeStats    nsi = harvestStats.items[i];
         ListViewItem lvi = new ListViewItem(nsi.name);
         lvi.SubItems.Add(nsi.TotalAttempts.ToString());
         lvi.SubItems.Add(String.Format("{0:0.00}%", nsi.PercentAttempts));
         lvi.SubItems.Add(nsi.TotalCollects.ToString());
         lvi.SubItems.Add(String.Format("{0:0.00}%", nsi.PercentCollects));
         lvi.SubItems.Add(nsi.TotalItems.ToString());
         lvi.SubItems.Add(String.Format("{0:0.00}%", nsi.PercentItems));
         lvi.SubItems.Add(nsi.TotalRares.ToString());
         lvi.SubItems.Add(String.Format("{0:0.00}%", nsi.PercentRares));
         lvi.SubItems.Add(nsi.TotalBountiful.ToString());
         lvi.SubItems.Add(String.Format("{0:0.00}%", nsi.PercentBountiful));
         lvi.SubItems.Add(String.Format("{0:0.00}%", nsi.TotalBonus));
         listView1.Items.Add(lvi);
     }
     ResizeLVCols();
     label1.Text = "Data Selected: Overview";
 }
Beispiel #19
0
            public async Task InitializeAsync()
            {
                this.blockinfo = new List <Blockinfo>();
                List <long> lst = blockinfoarr.Cast <long>().ToList();

                for (int i = 0; i < lst.Count; i += 2)
                {
                    this.blockinfo.Add(new Blockinfo {
                        extranonce = (int)lst[i], nonce = (uint)lst[i + 1]
                    });
                }

                // Note that by default, these tests run with size accounting enabled.
                this.network = KnownNetworks.RegTest;
                byte[] hex = Encoders.Hex.DecodeData("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f");
                this.scriptPubKey = new Script(new[] { Op.GetPushOp(hex), OpcodeType.OP_CHECKSIG });

                this.entry        = new TestMemPoolEntryHelper();
                this.ChainIndexer = new ChainIndexer(this.network);
                this.network.Consensus.Options = new ConsensusOptions();

                IDateTimeProvider dateTimeProvider = DateTimeProvider.Default;

                var loggerFactory = ExtendedLoggerFactory.Create();

                var nodeSettings      = new NodeSettings(this.network, args: new string[] { "-checkpoints" });
                var consensusSettings = new ConsensusSettings(nodeSettings);

                var inMemoryCoinView = new InMemoryCoinView(new HashHeightPair(this.ChainIndexer.Tip));
                var nodeStats        = new NodeStats(dateTimeProvider, loggerFactory);

                this.cachedCoinView = new CachedCoinView(this.network, new Checkpoints(), inMemoryCoinView, dateTimeProvider, new LoggerFactory(), nodeStats, consensusSettings);

                var signals       = new Signals.Signals(loggerFactory, null);
                var asyncProvider = new AsyncProvider(loggerFactory, signals, new NodeLifetime());

                var deployments = new NodeDeployments(this.network, this.ChainIndexer);

                var genesis = this.network.GetGenesis();

                var chainState = new ChainState()
                {
                    BlockStoreTip = new ChainedHeader(genesis.Header, genesis.GetHash(), 0)
                };

                var consensusRulesContainer = new ConsensusRulesContainer();

                foreach (var ruleType in this.network.Consensus.ConsensusRules.HeaderValidationRules)
                {
                    consensusRulesContainer.HeaderValidationRules.Add(Activator.CreateInstance(ruleType) as HeaderValidationConsensusRule);
                }
                foreach (var ruleType in this.network.Consensus.ConsensusRules.FullValidationRules)
                {
                    FullValidationConsensusRule rule = null;
                    if (ruleType == typeof(FlushUtxosetRule))
                    {
                        rule = new FlushUtxosetRule(new Mock <IInitialBlockDownloadState>().Object);
                    }
                    else
                    {
                        rule = Activator.CreateInstance(ruleType) as FullValidationConsensusRule;
                    }

                    consensusRulesContainer.FullValidationRules.Add(rule);
                }

                this.ConsensusRules = new PowConsensusRuleEngine(this.network, loggerFactory, dateTimeProvider, this.ChainIndexer, deployments, consensusSettings,
                                                                 new Checkpoints(), this.cachedCoinView, chainState, new InvalidBlockHashStore(dateTimeProvider), nodeStats, asyncProvider, consensusRulesContainer).SetupRulesEngineParent();

                this.consensus = ConsensusManagerHelper.CreateConsensusManager(this.network, chainState: chainState, inMemoryCoinView: inMemoryCoinView, chainIndexer: this.ChainIndexer, consensusRules: this.ConsensusRules);

                await this.consensus.InitializeAsync(chainState.BlockStoreTip);

                this.entry.Fee(11);
                this.entry.Height(11);

                var dateTimeProviderSet = new DateTimeProviderSet
                {
                    time    = dateTimeProvider.GetTime(),
                    timeutc = dateTimeProvider.GetUtcNow()
                };

                this.DateTimeProvider = dateTimeProviderSet;
                this.mempool          = new TxMempool(dateTimeProvider, new BlockPolicyEstimator(new MempoolSettings(nodeSettings), loggerFactory, nodeSettings), loggerFactory, nodeSettings);
                this.mempoolLock      = new MempoolSchedulerLock();

                // We can't make transactions until we have inputs
                // Therefore, load 100 blocks :)
                this.baseheight = 0;
                var blocks = new List <Block>();

                this.txFirst = new List <Transaction>();

                this.nonce = 0;

                for (int i = 0; i < this.blockinfo.Count; ++i)
                {
                    Block block = this.network.CreateBlock();
                    block.Header.HashPrevBlock = this.consensus.Tip.HashBlock;
                    block.Header.Version       = 1;
                    block.Header.Time          = Utils.DateTimeToUnixTime(this.ChainIndexer.Tip.GetMedianTimePast()) + 1;

                    Transaction txCoinbase = this.network.CreateTransaction();
                    txCoinbase.Version = 1;
                    txCoinbase.AddInput(new TxIn(new Script(new[] { Op.GetPushOp(this.blockinfo[i].extranonce), Op.GetPushOp(this.ChainIndexer.Height) })));
                    // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this)
                    txCoinbase.AddOutput(new TxOut(Money.Zero, new Script()));
                    block.AddTransaction(txCoinbase);

                    if (this.txFirst.Count == 0)
                    {
                        this.baseheight = this.ChainIndexer.Height;
                    }

                    if (this.txFirst.Count < 4)
                    {
                        this.txFirst.Add(block.Transactions[0]);
                    }

                    block.Header.Bits = block.Header.GetWorkRequired(this.network, this.ChainIndexer.Tip);

                    block.UpdateMerkleRoot();

                    while (!block.CheckProofOfWork())
                    {
                        block.Header.Nonce = ++this.nonce;
                    }

                    // Serialization sets the BlockSize property.
                    block = Block.Load(block.ToBytes(), this.network.Consensus.ConsensusFactory);

                    var res = await this.consensus.BlockMinedAsync(block);

                    if (res == null)
                    {
                        throw new InvalidOperationException();
                    }

                    blocks.Add(block);
                }

                // Just to make sure we can still make simple blocks
                this.newBlock = AssemblerForTest(this).Build(this.ChainIndexer.Tip, this.scriptPubKey);
                Assert.NotNull(this.newBlock);
            }
Beispiel #20
0
 public void Heavy()
 {
     NodeStats stats = new NodeStats(_node, _statsConfig);
 }
Beispiel #21
0
        public List <PerfNodeStats> GetMatchingNodes(string label)
        {
            var nodeIds = GetMatchNames(label);

            return(NodeStats.Where(n => nodeIds.Contains(n.Id)).ToList());
        }
Beispiel #22
0
        public long HeavyRep()
        {
            NodeStats stats = new NodeStats(_node, _statsConfig, _logManager);

            return(stats.CurrentNodeReputation);
        }
Beispiel #23
0
 public void Heavy()
 {
     NodeStats stats = new NodeStats(_node, _statsConfig, _logManager);
 }
Beispiel #24
0
 public ItemStats(string Name, NodeStats Parent)
 {
     name   = Name;
     parent = Parent;
 }