Exemple #1
0
        private static void RunWritePerformanceSingleThread <TP>() where TP : ProtocolWrapper, new()
        {
            using (ProtocolWrapper protocol = new TP())
            {
                protocol.Open("localhost");

                const string dropKeyspace     = "drop keyspace Tests";
                const string truncateTable    = "truncate Tests.stresstest";
                const string truncateEvents   = "truncate system_traces.events";
                const string truncateSessions = "truncate system_traces.sessions";
                const string createKeyspace   = "create keyspace Tests with replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}";
                const string createTable      = "create table Tests.stresstest (strid varchar,intid int, primary key (strid))";
                const string insertPerf       = "insert into Tests.stresstest (intid, strid) values (?, ?)";

                try
                {
                    protocol.Query(dropKeyspace);
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch
                // ReSharper restore EmptyGeneralCatchClause
                {
                }

                protocol.Query(createKeyspace);
                protocol.Query(createTable);
                protocol.Query(truncateTable);
                protocol.Query(truncateSessions);
                protocol.Query(truncateEvents);
                protocol.Prepare(insertPerf);

                PerformanceInstrumentation.Initialize();

                long totalTime = ExecuteStressTest(protocol);

                // ExportTracingInfo(protocol, totalTime);

                protocol.Query(dropKeyspace);
            }
        }