Exemplo n.º 1
0
        /// <summary>
        /// Run multithreaded stress string-related operations.
        /// </summary>
        /// <param name="worker">The worker to use.</param>
        private static void StringStressThread(PerfTestWorker worker)
        {
            const int NumRecords   = 10 * 1000;
            const int NumRetrieves = 100;

            worker.InsertStringRecordsWithBracketOperator(NumRecords);
            worker.RepeatedlyRetrieveOneStringRecord(NumRetrieves);
            worker.RepeatedlyRetrieveOneStringRecordWithTryGetValue(NumRetrieves);
            worker.RepeatedlyRetrieveOneStringRecordWithBracketOperator(NumRetrieves);
            worker.RetrieveAllStringRecords();

            worker.InsertStringRecordsWithAddFunction(NumRecords);
            worker.RepeatedlyRetrieveOneStringRecord(NumRetrieves);
            worker.RepeatedlyRetrieveOneStringRecordWithTryGetValue(NumRetrieves);
            worker.RepeatedlyRetrieveOneStringRecordWithBracketOperator(NumRetrieves);
            worker.RetrieveAllStringRecords();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Insert some string records and then retrieve them.
        /// </summary>
        private void InsertReadSeekStrings()
        {
            const int NumRecords = 100 * 1000;

            long[] keys = this.GetRandomKeys(NumRecords);
            IEnumerable <string> stringKeys = keys.Select((key) => { return(key.ToString()); });

            using (var worker = new PerfTestWorker(
                       this.longDictionary,
                       this.longDatabase,
                       this.stringDictionary,
                       this.stringDatabase))
            {
                TimeAction("Insert string record with Add()s", () => worker.InsertStringRecordsWithAddFunction(NumRecords / 2));
                TimeAction("Insert string records with []", () => worker.InsertStringRecordsWithBracketOperator(NumRecords / 2));
                TimeAction("Read one string record", () => worker.RepeatedlyRetrieveOneStringRecord(NumRecords));
                TimeAction("Read one string record with JetRetrieveColumns", () => worker.RepeatedlyRetrieveOneStringRecordWithTryGetValue(NumRecords));
                TimeAction("Read one string record with RetrieveColumns", () => worker.RepeatedlyRetrieveOneStringRecordWithBracketOperator(NumRecords));
                TimeAction("Read all string records", worker.RetrieveAllStringRecords);
                TimeAction("Seek to all string records randomly", () => worker.SeekToAllStringRecords(stringKeys));
            }
        }