Exemplo n.º 1
0
        public void StrataTest1()
        {
            var clientEst = new StrataEstimator(true);

            var _clientDic = DataGen.Gen(1000, 0).ToDictionary(currItem => currItem.Key, currItem => currItem.Value);
            var _serverDic = DataGen.Gen(1000, 4).ToDictionary(currItem => currItem.Key, currItem => currItem.Value);

            clientEst.Encode(_clientDic);

            var serverEst = new StrataEstimator(true);
            serverEst.Encode(_serverDic);

            var diff = serverEst - clientEst;

            var n = diff.Estimate();
            Assert.IsTrue(n > 0);
        }
Exemplo n.º 2
0
        static double StressTestStrataEstimator(int size, int changedPer, out int estimatedD0)
        {
            var clientDic = DataGen.Gen(size, 0).ToDictionary(currItem => currItem.Key, currItem => currItem.Value);
            var serverDic = DataGen.Gen(size, changedPer).ToDictionary(currItem => currItem.Key, currItem => currItem.Value);

            var clientEst = new StrataEstimator(true);
            clientEst.Encode(clientDic);
            var serverEst = new StrataEstimator(true);
            serverEst.Encode(serverDic);

            var diffEst = serverEst - clientEst;

            estimatedD0 = diffEst.Estimate();
            Console.WriteLine("Estimated d0 = {0}", estimatedD0);

            var realD0 = changedPer * size / 100 * 1.5;
            var diff = (double)estimatedD0 / realD0;
            return diff;
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            _dataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "aaa"); ;

            //RunFunctionTimed(() => GenServerData(2000000, 50));
            //RunFunctionTimed(() => GenPatch1File());

            //RunFunctionTimed(() => GenPatch2File());
            var clientDic = DataGen.Gen(1000, 0).ToDictionary(currItem => currItem.Key, currItem => currItem.Value);

            var clientEst = new StrataEstimator(true);
            clientEst.Encode(clientDic);
            using (var f = File.Create(Path.Combine(_dataDir, "clientstrata.dat")))
            {
                Serializer.Serialize(f, clientEst);
            }

            var serverDic = DataGen.Gen(1000, 4).ToDictionary(currItem => currItem.Key, currItem => currItem.Value);

            var serverEst = new StrataEstimator(true);
            serverEst.Encode(serverDic);

            var n1 = 0;

            using (var f = File.OpenRead(Path.Combine(_dataDir, "clientstrata.dat")))
            {
                var readClientEst = Serializer.Deserialize<StrataEstimator>(f);
                var diffEst = serverEst - readClientEst;
                n1 = diffEst.Estimate();
            }

            var dEst = serverEst - clientEst;
            var n2 = dEst.Estimate();

            var a =  0;
        }
Exemplo n.º 4
0
        private void GenServerStrataClicked(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Start generating server strata");
            RunFunctionTimed(() =>
            {
                var serverStrata = new StrataEstimator(true);
                serverStrata.Encode(_serverDic);

                using (var f = File.Create(System.IO.Path.Combine(DataDir, Helper.SEFileName)))
                {
                    Serializer.Serialize(f, serverStrata);
                }
            });
        }
Exemplo n.º 5
0
        public void StrataEstimatorClicked(View v)
        {
            Console.WriteLine("Estimate strata");

            RunFunctionTimed(() =>
            {
                var clientStrata = new StrataEstimator(true);
                clientStrata.Encode(_clientDic);

                StrataEstimator serverStrata;
                using (var f = File.OpenRead(Path.Combine(DbManager.AppDir, Helper.SEFileName)))
                {
                    serverStrata = Serializer.Deserialize<StrataEstimator>(f);
                }
                serverStrata.SetHashFunctions();
                var diffStra = serverStrata - clientStrata;
                var estimatedD0 = diffStra.Estimate();
                Console.WriteLine("estimated d0: {0}", estimatedD0);
            });
            Console.WriteLine("Done estimating strata");
        }