本文整理汇总了C#中PerfTracker.Record方法的典型用法代码示例。如果您正苦于以下问题:C# PerfTracker.Record方法的具体用法?C# PerfTracker.Record怎么用?C# PerfTracker.Record使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerfTracker
的用法示例。
在下文中一共展示了PerfTracker.Record方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadInternal
private static long ReadInternal(IEnumerable<uint> ids, PerfTracker perfTracker, StorageEnvironment env)
{
var ms = new byte[4096];
using (var tx = env.NewTransaction(TransactionFlags.Read))
{
var sw = Stopwatch.StartNew();
long v = 0;
foreach (var id in ids)
{
var key = id.ToString("0000000000000000");
var readResult = tx.State.Root.Read(tx, key);
int reads = 0;
while ((reads = readResult.Reader.Read(ms, 0, ms.Length)) > 0)
{
v += reads;
}
}
perfTracker.Record(sw.ElapsedMilliseconds);
return v;
}
}
示例2: WriteInternalBatch
private List<PerformanceRecord> WriteInternalBatch(
string operation,
IEnumerator<TestData> enumerator,
long itemsPerBatch,
long numberOfBatches,
PerfTracker perfTracker,
StorageEnvironment env)
{
var sw = new Stopwatch();
byte[] valueToWrite = null;
var records = new List<PerformanceRecord>();
for (var b = 0; b < numberOfBatches; b++)
{
sw.Restart();
long v = 0;
using (var batch = new WriteBatch())
{
for (var i = 0; i < itemsPerBatch; i++)
{
enumerator.MoveNext();
valueToWrite = GetValueToWrite(valueToWrite, enumerator.Current.ValueSize);
v += valueToWrite.Length;
batch.Add(enumerator.Current.Id.ToString("0000000000000000"), new MemoryStream(valueToWrite), "Root");
}
env.Writer.Write(batch);
}
sw.Stop();
perfTracker.Record(sw.ElapsedMilliseconds);
records.Add(new PerformanceRecord
{
Bytes = v,
Operation = operation,
Time = DateTime.Now,
Duration = sw.ElapsedMilliseconds,
ProcessedItems = itemsPerBatch
});
}
return records;
}
示例3: WriteInternal
private List<PerformanceRecord> WriteInternal(
string operation,
int itemsPerTransaction,
int numberOfTransactions,
PerfTracker perfTracker,
StorageEnvironment env,
IEnumerator<TestData> enumerator)
{
var sw = new Stopwatch();
byte[] valueToWrite = null;
var records = new List<PerformanceRecord>();
for (var transactions = 0; transactions < numberOfTransactions; transactions++)
{
sw.Restart();
using (var tx = env.NewTransaction(TransactionFlags.ReadWrite))
{
for (var i = 0; i < itemsPerTransaction; i++)
{
enumerator.MoveNext();
valueToWrite = GetValueToWrite(valueToWrite, enumerator.Current.ValueSize);
tx.State.Root.Add(tx, enumerator.Current.Id.ToString("0000000000000000"), new MemoryStream(valueToWrite));
}
tx.Commit();
perfTracker.Record(sw.ElapsedMilliseconds);
}
sw.Stop();
records.Add(new PerformanceRecord
{
Operation = operation,
Time = DateTime.Now,
Duration = sw.ElapsedMilliseconds,
ProcessedItems = itemsPerTransaction
});
}
return records;
}
示例4: WriteInternalAsync
private async Task<List<PerformanceRecord>> WriteInternalAsync(string operation,
IEnumerator<TestData> enumerator,
long itemsPerTransaction, long numberOfTransactions, PerfTracker perfTracker, FdbDatabase db)
{
var sw = new Stopwatch();
byte[] valueToWrite = null;
var records = new List<PerformanceRecord>();
var location = db.GlobalSpace;
sw.Restart();
for (int transactions = 0; transactions < numberOfTransactions; transactions++)
{
sw.Restart();
using (IFdbTransaction tx = db.BeginTransaction())
{
for (int i = 0; i < itemsPerTransaction; i++)
{
enumerator.MoveNext();
valueToWrite = GetValueToWrite(valueToWrite, enumerator.Current.ValueSize);
tx.Set(location.Pack(enumerator.Current.Id), Slice.Create(valueToWrite));
}
await tx.CommitAsync();
perfTracker.Record(sw.ElapsedMilliseconds);
}
sw.Stop();
records.Add(new PerformanceRecord
{
Operation = operation,
Time = DateTime.Now,
Duration = sw.ElapsedMilliseconds,
ProcessedItems = itemsPerTransaction
});
}
sw.Stop();
return records;
}
示例5: ReadInternalAsync
private static async Task<long> ReadInternalAsync(IEnumerable<uint> ids, PerfTracker perfTracker, FdbDatabase db)
{
const int BATCH_SIZE = 1000;
var list = new List<int>(BATCH_SIZE);
var location = db.GlobalSpace;
Stopwatch sw = Stopwatch.StartNew();
long v = 0;
foreach (int id in ids)
{
list.Add(id);
if (list.Count >= BATCH_SIZE)
{
using (var tx = db.BeginReadOnlyTransaction())
{
var slices = await tx.GetValuesAsync(location.PackRange(list));
v += slices.Sum(x=>x.Count);
}
list.Clear();
}
}
if (list.Count > 0)
{
using (var tx = db.BeginReadOnlyTransaction())
{
var slices = await tx.GetValuesAsync(location.PackRange(list));
v += slices.Sum(x => x.Count);
}
}
perfTracker.Record(sw.ElapsedMilliseconds);
return v;
}
示例6: WriteInternal
private List<PerformanceRecord> WriteInternal(
string operation,
IEnumerator<TestData> enumerator,
long itemsPerTransaction,
long numberOfTransactions,
PerfTracker perfTracker,
rndseq Rflag,
LightningEnvironment env,
LightningDatabase db)
{
byte[] valueToWrite = null;
var records = new List<PerformanceRecord>();
var sw = new Stopwatch();
LightningDB.PutOptions putflags = LightningDB.PutOptions.None;
if (Rflag == rndseq.SEQ)
putflags = LightningDB.PutOptions.AppendData;
for (var transactions = 0; transactions < numberOfTransactions; transactions++)
{
sw.Restart();
using (var tx = env.BeginTransaction())
{
for (var i = 0; i < itemsPerTransaction; i++)
{
enumerator.MoveNext();
valueToWrite = GetValueToWrite(valueToWrite, enumerator.Current.ValueSize);
tx.Put(db, Encoding.UTF8.GetBytes(enumerator.Current.Id.ToString("0000000000000000")), valueToWrite, putflags);
}
tx.Commit();
}
sw.Stop();
perfTracker.Record(sw.ElapsedMilliseconds);
records.Add(new PerformanceRecord
{
Operation = operation,
Time = DateTime.Now,
Duration = sw.ElapsedMilliseconds,
ProcessedItems = itemsPerTransaction
});
}
sw.Stop();
return records;
}
示例7: WriteInternal
private List<PerformanceRecord> WriteInternal(string operation, IEnumerator<TestData> enumerator, long itemsPerTransaction, long numberOfTransactions, PerfTracker perfTracker)
{
var sw = new Stopwatch();
byte[] valueToWrite = null;
var records = new List<PerformanceRecord>();
using (var connection = new SQLiteConnection(connectionString))
{
connection.Open();
sw.Restart();
for (var transactions = 0; transactions < numberOfTransactions; transactions++)
{
sw.Restart();
using (var tx = connection.BeginTransaction())
{
for (var i = 0; i < itemsPerTransaction; i++)
{
enumerator.MoveNext();
valueToWrite = GetValueToWrite(valueToWrite, enumerator.Current.ValueSize);
using (var command = new SQLiteCommand("INSERT INTO Items (Id, Value) VALUES (@id, @value)", connection))
{
command.Parameters.Add("@id", DbType.Int32, 4).Value = enumerator.Current.Id;
command.Parameters.Add("@value", DbType.Binary, valueToWrite.Length).Value = valueToWrite;
var affectedRows = command.ExecuteNonQuery();
Debug.Assert(affectedRows == 1);
}
}
tx.Commit();
}
sw.Stop();
perfTracker.Record(sw.ElapsedMilliseconds);
records.Add(new PerformanceRecord
{
Operation = operation,
Time = DateTime.Now,
Duration = sw.ElapsedMilliseconds,
ProcessedItems = itemsPerTransaction
});
}
sw.Stop();
}
return records;
}
示例8: ReadInternal
private static long ReadInternal(IEnumerable<uint> ids, PerfTracker perfTracker, SQLiteConnection connection)
{
var buffer = new byte[4096];
using (var tx = connection.BeginTransaction())
{
long v = 0;
var sw = Stopwatch.StartNew();
foreach (var id in ids)
{
using (var command = new SQLiteCommand("SELECT Value FROM Items WHERE ID = " + id, connection))
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
long bytesRead;
long fieldOffset = 0;
while ((bytesRead = reader.GetBytes(0, fieldOffset, buffer, 0, buffer.Length)) > 0)
{
fieldOffset += bytesRead;
v += bytesRead;
}
}
}
}
perfTracker.Record(sw.ElapsedMilliseconds);
return v;
}
}
示例9: ReadInternal
private long ReadInternal(IEnumerable<uint> ids, PerfTracker perfTracker, Instance instance)
{
Table table;
JET_COLUMNID primaryColumnId;
JET_COLUMNID secondaryColumnId;
using (var session = OpenSession(instance, out table, out primaryColumnId, out secondaryColumnId))
{
var sw = Stopwatch.StartNew();
Api.JetSetCurrentIndex(session, table, "by_key");
long v = 0;
foreach (var id in ids)
{
Api.MoveBeforeFirst(session, table);
Api.MakeKey(session, table, id, MakeKeyGrbit.NewKey);
Api.JetSeek(session, table, SeekGrbit.SeekEQ);
var value = Api.RetrieveColumn(session, table, secondaryColumnId);
v += value.Length;
Debug.Assert(value != null);
}
perfTracker.Record(sw.ElapsedMilliseconds);
return v;
}
}
示例10: WriteInternal
private List<PerformanceRecord> WriteInternal(
string operation,
IEnumerator<TestData> enumerator,
long itemsPerTransaction,
long numberOfTransactions,
PerfTracker perfTracker,
Instance instance)
{
byte[] valueToWrite = null;
var records = new List<PerformanceRecord>();
var sw = new Stopwatch();
Table table;
JET_COLUMNID primaryColumnId;
JET_COLUMNID secondaryColumnId;
using (var session = OpenSession(instance, out table, out primaryColumnId, out secondaryColumnId))
{
for (var transactions = 0; transactions < numberOfTransactions; transactions++)
{
sw.Restart();
long v = 0;
using (var tx = new Transaction(session))
{
for (var i = 0; i < itemsPerTransaction; i++)
{
enumerator.MoveNext();
var testData = enumerator.Current;
valueToWrite = GetValueToWrite(valueToWrite, testData.ValueSize);
v += valueToWrite.Length;
Api.JetPrepareUpdate(session, table, JET_prep.Insert);
Api.SetColumn(session, table, primaryColumnId, testData.Id);
Api.SetColumn(session, table, secondaryColumnId, valueToWrite);
Api.JetUpdate(session, table);
}
tx.Commit(CommitTransactionGrbit.None);
}
sw.Stop();
perfTracker.Record(sw.ElapsedMilliseconds);
records.Add(
new PerformanceRecord
{
Bytes = v,
Operation = operation,
Time = DateTime.Now,
Duration = sw.ElapsedMilliseconds,
ProcessedItems = itemsPerTransaction,
});
}
sw.Stop();
}
return records;
}