コード例 #1
0
ファイル: BinaryModifier.cs プロジェクト: brianrob/tests
        public static void ApplyZeroBlocks(string pathToFile, ZeroBlockList committedList, ZeroBlockList attemptingList)
        {
            using (FileStream stream = new FileStream(pathToFile, FileMode.Open, FileAccess.Write))
            {
                foreach (ulong addr in committedList)
                {
                    long seekAddr = stream.Seek((long)addr, SeekOrigin.Begin);
                    if (seekAddr != (long)addr)
                    {
                        throw new InvalidOperationException("Unable to seek to the requested address.");
                    }

                    stream.Write(Zeros, 0, (int)Config.BlockSize);
                }

                foreach (ulong addr in attemptingList)
                {
                    long seekAddr = stream.Seek((long)addr, SeekOrigin.Begin);
                    if (seekAddr != (long)addr)
                    {
                        throw new InvalidOperationException("Unable to seek to the requested address.");
                    }

                    stream.Write(Zeros, 0, (int)Config.BlockSize);
                }
            }
        }
コード例 #2
0
        public Experiment(ZeroBlockList committedList, ZeroBlockList attemptingList)
        {
            // Assign an experiment number and increment the global counter.
            _experimentNumber = ExperimentCounter++;

            // Save the zero block lists.
            _committedList  = committedList;
            _attemptingList = attemptingList;
        }
コード例 #3
0
        public void Complete()
        {
            if (Succeeded)
            {
                ZeroBlockList committedList = new ZeroBlockList();
                committedList.AddRange(_committedList);
                committedList.AddRange(_attemptingList);
                _committedList = committedList;

                _attemptingList = new ZeroBlockList();
            }

            Delete();
        }
コード例 #4
0
ファイル: ExperimentGenerator.cs プロジェクト: brianrob/tests
        private Experiment[] GeneratePermutations(Experiment baseExperiment, int numExperiments)
        {
            Log(baseExperiment, $"Generating {numExperiments} experiments based on this successful experiment.");
            Experiment[] experiments = new Experiment[numExperiments];
            for (int i = 0; i < numExperiments; i++)
            {
                // Generate the next block list.
                ZeroBlockList attemptingList = new ZeroBlockList();
                while (true)
                {
                    ulong value = GenerateRandomBlock();
                    if (!baseExperiment.CommittedList.Contains(value))
                    {
                        attemptingList.Add(value);
                        break;
                    }
                }

                // Create a new experiment.
                experiments[i] = new Experiment(baseExperiment.CommittedList, attemptingList);
            }

            return(experiments);
        }
コード例 #5
0
ファイル: ZeroBlockList.cs プロジェクト: brianrob/tests
 private ZeroBlockList(ZeroBlockList list)
 {
     _set.UnionWith(list);
 }