Exemplo n.º 1
0
        /*
         * Runs the neo4j test query n times
         * and returns the min, mean, max, standard dev.
         * */
        public double[] runQueryTest(int n, string query)
        {
            long seed  = Environment.TickCount;
            int  count = 100000000;
            long x     = 0;


            double[]  results     = { 999999, 0, -999999, 0 };
            double[]  tempResults = new double[n];
            Stopwatch watch       = new Stopwatch();

            watch.Reset();
            watch.Start();
            while (watch.ElapsedMilliseconds < 1200)  // A Warmup of 1000-1500 mS
            // stabilizes the CPU cache and pipeline.
            {
                x = TestFunction(seed, count); // Warmup
            }
            watch.Stop();


            watch.Reset();

            //           watch.Start();
            neo4jclient connection = neo4jclient.setupConnection("localhost", 7687, "neo4j", "abc123#$");

            connection.setStatement(query);
            connection.init();


            for (int i = 0; i < n; i++)
            {
                watch.Start();
                connection.execStatement();
                //                connection.session.Dispose();
                //                connection.driver.Dispose();
                double t = connection.result.Summary.ResultAvailableAfter.TotalMilliseconds;

                watch.Stop();
                double milli = watch.ElapsedTicks * (1.0 / Stopwatch.Frequency) * 1000;
                if (milli < results[0])
                {
                    results[0] = milli;
                }
                else if (milli > results[2])
                {
                    results[2] = milli;
                }
                tempResults[i] = milli;
                results[1]    += milli;
                watch.Reset();
            }
            results[1] = results[1] / n;
            for (int ix = 0; ix < n; ix++)
            {
                double diff = Math.Pow((tempResults[ix] - results[1]), 2.0);
                results[3] += diff;
            }
            results[3] = results[3] / n;
            results[3] = Math.Sqrt(results[3]);
            return(results);
        }
Exemplo n.º 2
0
        public static neo4jclient setupConnection(string hostURL = "localhost", int hostPort = 7687, string username = "******", string password = "******")
        {
            var conn = new neo4jclient(hostURL, hostPort, username, password);

            return(conn);
        }