本文整理汇总了C#中Record.Deallocate方法的典型用法代码示例。如果您正苦于以下问题:C# Record.Deallocate方法的具体用法?C# Record.Deallocate怎么用?C# Record.Deallocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.Deallocate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static public void Main(string[] args)
{
const int pagePoolSize = 256*1024*1024;
const int nRecords = 1024*1024;
Storage db = StorageFactory.Instance.CreateStorage();
db.SetProperty("perst.concurrent.iterator", true);
db.Open("testregex.dbs", pagePoolSize);
#if USE_GENERICS
RegexIndex<Record> index = (RegexIndex<Record>)db.Root;
if (index == null) {
index = db.CreateRegexIndex<Record>("key");
db.Root = index;
}
#else
RegexIndex index = (RegexIndex)db.Root;
if (index == null) {
index = db.CreateRegexIndex(typeof(Record), "key");
db.Root = index;
}
#endif
DateTime start = DateTime.Now;
for (int i = 0; i < nRecords; i++) {
Record rec = new Record();
rec.key = i.ToString("x");
index.Put(rec);
}
db.Commit();
Console.WriteLine("Elapsed time for inserting " + nRecords + " records: " + (DateTime.Now - start));
start = DateTime.Now;
int n = 0;
foreach (Record rec in index.Match("%Abcd%")) {
n += 1;
Debug.Assert(rec.key.IndexOf("abcd") >= 0);
}
Console.WriteLine("Elapsed time for query LIKE '%abcd%': " + (DateTime.Now - start));
Debug.Assert(n == 16*2);
start = DateTime.Now;
n = 0;
foreach (Record rec in index.Match("1_2_3")) {
n += 1;
}
Console.WriteLine("Elapsed time for query LIKE '1_2_3': " + (DateTime.Now - start));
Debug.Assert(n == 16*16);
start = DateTime.Now;
foreach (Record rec in index) {
index.Remove(rec);
rec.Deallocate();
}
Debug.Assert(!index.GetEnumerator().MoveNext());
Console.WriteLine("Elapsed time for deleting " + nRecords + " records: " + (DateTime.Now - start));
db.Close();
}
示例2: Main
public static void Main(string[] args)
{
Storage db = StorageFactory.Instance.CreateStorage();
db.Open("testmaxoid.dbs", pagePoolSize);
int i;
FieldIndex root = (FieldIndex) db.GetRoot();
if (root == null)
{
root = db.CreateFieldIndex(typeof(Record), "key", true);
db.SetRoot(root);
}
long start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
for (i = 0; i < nRecords; i++)
{
Record rec = new Record(i);
root.Put(rec);
if (i % 1000000 == 0)
{
Console.Out.Write("Insert " + i + " records\r");
db.Commit();
}
}
db.Commit();
Console.Out.WriteLine("Elapsed time for inserting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
for (i = 0; i < nRecords; i++)
{
Record rec = (Record) root.Get(new Key(i));
Assert.That(rec != null && rec.key == i);
}
Console.Out.WriteLine("Elapsed time for performing " + nRecords + " index searches: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
System.Collections.IEnumerator iterator = root.GetEnumerator();
for (i = 0; iterator.MoveNext(); i++)
{
Record rec = (Record) iterator.Current;
Assert.That(rec.key == i);
}
Assert.That(i == nRecords);
Console.Out.WriteLine("Elapsed time for iterating through " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
for (i = 0; i < nRecords; i++)
{
Record rec = (Record) root.Remove(new Key(i));
Assert.That(rec.key == i);
rec.Deallocate();
}
Console.Out.WriteLine("Elapsed time for deleting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
db.Close();
}
示例3: Main
static public void Main(string[] args)
{
int i, j;
Storage db = StorageFactory.Instance.CreateStorage();
db.SetProperty("perst.concurrent.iterator", true);
db.Open("testrnd.dbs", pagePoolSize);
#if USE_GENERICS
FieldIndex<int,Record> root = (FieldIndex<int,Record>)db.Root;
if (root == null)
{
root = db.CreateRandomAccessFieldIndex<int,Record>("i", true);
db.Root = root;
}
#else
FieldIndex root = (FieldIndex)db.Root;
if (root == null)
{
root = db.CreateRandomAccessFieldIndex(typeof(Record), "i", true);
db.Root = root;
}
#endif
DateTime start = DateTime.Now;
for (i = 0, j = 0; i < nRecords; i++, j += step) {
Record rec = new Record();
rec.i = j % nRecords;
root.Put(rec);
}
db.Commit();
Console.WriteLine("Elapsed time for inserting " + nRecords + " records: " + (DateTime.Now - start));
start = DateTime.Now;
for (i = 0; i < nRecords; i++) {
#if USE_GENERICS
Record rec = root[i];
#else
Record rec = (Record)root[i];
#endif
Debug.Assert(rec.i == i);
Debug.Assert(root.IndexOf(new Key(i)) == i);
}
Console.WriteLine("Elapsed time for performing " + nRecords + " Get operations: " + (DateTime.Now - start));
start = DateTime.Now;
for (i = 0; i < nRecords; i++) {
#if USE_GENERICS
Record rec = root.GetAt(i);
#else
Record rec = (Record)root.GetAt(i);
#endif
Debug.Assert(rec.i == i);
}
Console.WriteLine("Elapsed time for performing " + nRecords + " GetAt operations: " + (DateTime.Now - start));
start = DateTime.Now;
i = nRecords/2;
IDictionaryEnumerator e = root.GetDictionaryEnumerator(nRecords/2, IterationOrder.AscentOrder);
while (e.MoveNext())
{
Debug.Assert((int)e.Key == i && ((Record)e.Value).i == i);
i += 1;
}
Debug.Assert(i == nRecords);
i = nRecords/2-1;
e = root.GetDictionaryEnumerator(nRecords/2-1, IterationOrder.DescentOrder);
while (e.MoveNext())
{
Debug.Assert((int)e.Key == i && ((Record)e.Value).i == i);
i -= 1;
}
Debug.Assert(i == -1);
Console.WriteLine("Elapsed time for iteration through " + nRecords + " records: " + (DateTime.Now - start));
start = DateTime.Now;
for (i = 0, j = 0; i < nRecords; i += step, j++) {
#if USE_GENERICS
Record rec = root.GetAt(i-j);
#else
Record rec = (Record)root.GetAt(i-j);
#endif
Debug.Assert(rec.i == i);
root.Remove(rec);
rec.Deallocate();
}
Console.WriteLine("Elapsed time for deleting " + nRecords/step + " records: " + (DateTime.Now - start));
root.Clear();
Debug.Assert(!root.GetEnumerator().MoveNext());
db.Close();
}
示例4: Main
//.........这里部分代码省略.........
db.SetRoot(root);
}
Index intIndex = root.intIndex;
Index strIndex = root.strIndex;
long start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
long key = 1999;
int i2;
for (i2 = 0; i2 < nRecords; i2++)
{
Record rec = new Record();
key = (3141592621L * key + 2718281829L) % 1000000007L;
rec.intKey = key;
rec.strKey = Convert.ToString(key);
intIndex.Put(new Key(rec.intKey), rec);
strIndex.Put(new Key(rec.strKey), rec);
/*
if (i % 100000 == 0) {
System.out.print("Insert " + i + " records\r");
db.Commit();
}
*/
}
if (serializableTransaction)
{
db.EndThreadTransaction();
db.BeginThreadTransaction(StorageConstants.SERIALIZABLE_TRANSACTION);
}
else
{
db.Commit();
}
//db.Gc();
Console.Out.WriteLine("Elapsed time for inserting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = 1999;
for (i2 = 0; i2 < nRecords; i2++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
Record rec1 = (Record) intIndex.Get(new Key(key));
Record rec2 = (Record) strIndex.Get(new Key(Convert.ToString(key)));
Assert.That(rec1 != null && rec1 == rec2);
}
Console.Out.WriteLine("Elapsed time for performing " + nRecords * 2 + " index searches: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = System.Int64.MinValue;
i2 = 0;
foreach (Record rec in intIndex)
{
Assert.That(rec.intKey >= key);
key = rec.intKey;
++i2;
}
Assert.That(i2 == nRecords);
string strKey = "";
i2 = 0;
foreach (Record rec in strIndex)
{
Assert.That(String.CompareOrdinal(rec.strKey, strKey) >= 0);
strKey = rec.strKey;
i2++;
}
Assert.That(i2 == nRecords);
Console.Out.WriteLine("Elapsed time for iterating through " + (nRecords * 2) + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
//UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior.
Hashtable map = db.GetMemoryDump();
Console.Out.WriteLine("Memory usage");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
foreach (MemoryUsage usage in map.Values)
{
Console.Out.WriteLine(" " + usage.cls.FullName + ": instances=" + usage.nInstances + ", total size=" + usage.totalSize + ", allocated size=" + usage.allocatedSize);
}
Console.Out.WriteLine("Elapsed time for memory dump: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = 1999;
for (i2 = 0; i2 < nRecords; i2++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
Record rec = (Record) intIndex.Get(new Key(key));
Record removed = (Record) intIndex.Remove(new Key(key));
Assert.That(removed == rec);
//strIndex.Remove(new Key(Long.toString(key)), rec);
strIndex.Remove(new Key(Convert.ToString(key)));
rec.Deallocate();
}
Assert.That(!intIndex.GetEnumerator().MoveNext());
Assert.That(!strIndex.GetEnumerator().MoveNext());
Assert.That(!intIndex.GetEnumerator(null, null, IndexSortOrder.Descent).MoveNext());
Assert.That(!strIndex.GetEnumerator(null, null, IndexSortOrder.Descent).MoveNext());
Assert.That(!intIndex.GetEnumerator(null, null, IndexSortOrder.Ascent).MoveNext());
Assert.That(!strIndex.GetEnumerator(null, null, IndexSortOrder.Ascent).MoveNext());
Console.Out.WriteLine("Elapsed time for deleting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
db.Close();
}
示例5: Main
static public void Main(string[] args)
{
int i;
Storage db = StorageFactory.Instance.CreateStorage();
db.Open("testlist2.dbs", pagePoolSize);
#if USE_GENERICS
IPersistentList<Record> root = (IPersistentList<Record>)db.Root;
if (root == null)
{
root = db.CreateList<Record>();
db.Root = root;
}
#else
IPersistentList root = (IPersistentList)db.Root;
if (root == null)
{
root = db.CreateList();
db.Root = root;
}
#endif
DateTime start = DateTime.Now;
for (i = 0; i < nRecords/2; i++) {
Record rec = new Record();
rec.i = i*2;
root.Add(rec);
}
for (i = 1; i < nRecords; i+=2) {
Record rec = new Record();
rec.i = i;
root.Insert(i, rec);
}
db.Commit();
Console.WriteLine("Elapsed time for inserting " + nRecords + " records: " + (DateTime.Now - start));
start = DateTime.Now;
for (i = 0; i < nRecords; i++) {
#if USE_GENERICS
Record rec = root[i];
#else
Record rec = (Record)root[i];
#endif
Debug.Assert(rec.i == i);
}
Console.WriteLine("Elapsed time for performing " + nRecords + " gets: " + (DateTime.Now - start));
start = DateTime.Now;
i = 0;
foreach (Record rec in root)
{
Debug.Assert(rec.i == i);
i += 1;
}
Debug.Assert(i == nRecords);
Console.WriteLine("Elapsed time for iteration through " + nRecords + " records: " + (DateTime.Now - start));
start = DateTime.Now;
for (i = 0; i < nRecords; i++) {
#if USE_GENERICS
Record rec = root[0];
#else
Record rec = (Record)root[0];
#endif
Debug.Assert(rec.i == i);
root.RemoveAt(0);
rec.Deallocate();
}
Debug.Assert(!root.GetEnumerator().MoveNext());
Console.WriteLine("Elapsed time for deleting " + nRecords + " records: " + (DateTime.Now - start));
db.Close();
}
示例6: Main
public static void Main(string[] args)
{
Storage db = StorageFactory.Instance.CreateStorage();
for (int i = 0; i < args.Length; i++)
{
if ("altbtree".Equals(args[i]))
{
db.SetProperty("perst.alternative.btree", true);
}
}
db.Open("testcidx.dbs", pagePoolSize);
FieldIndex root = (FieldIndex) db.GetRoot();
if (root == null)
{
root = db.CreateFieldIndex(typeof(Record), new string[]{"intKey", "strKey"}, true);
db.SetRoot(root);
}
long start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
long key = 1999;
int i2;
for (i2 = 0; i2 < nRecords; i2++)
{
Record rec = new Record();
key = (3141592621L * key + 2718281829L) % 1000000007L;
rec.intKey = (int) (SupportClass.URShift(key, 32));
rec.strKey = Convert.ToString((int) key);
root.Put(rec);
}
db.Commit();
Console.Out.WriteLine("Elapsed time for inserting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = 1999;
int minKey = System.Int32.MaxValue;
int maxKey = System.Int32.MinValue;
for (i2 = 0; i2 < nRecords; i2++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
int intKey = (int) (SupportClass.URShift(key, 32));
string strKey = Convert.ToString((int) key);
Record rec = (Record) root.Get(new Key(new System.Object[]{(System.Int32) intKey, strKey}));
Assert.That(rec != null && rec.intKey == intKey && rec.strKey.Equals(strKey));
if (intKey < minKey)
{
minKey = intKey;
}
if (intKey > maxKey)
{
maxKey = intKey;
}
}
Console.Out.WriteLine("Elapsed time for performing " + nRecords + " index searches: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
System.Collections.IEnumerator iterator = root.GetEnumerator(new Key((System.Int32)minKey, ""), new Key((System.Int32)(maxKey + 1), "???"), IndexSortOrder.Ascent);
int n = 0;
string prevStr = "";
int prevInt = minKey;
while (iterator.MoveNext())
{
Record rec = (Record) iterator.Current;
Assert.That(rec.intKey > prevInt || rec.intKey == prevInt && String.CompareOrdinal(rec.strKey, prevStr) > 0);
prevStr = rec.strKey;
prevInt = rec.intKey;
n += 1;
}
Assert.That(n == nRecords);
iterator = root.GetEnumerator(new Key((System.Int32)minKey, "", false), new Key((System.Int32)(maxKey + 1), "???", false), IndexSortOrder.Descent);
n = 0;
prevInt = maxKey + 1;
while (iterator.MoveNext())
{
Record rec = (Record) iterator.Current;
Assert.That(rec.intKey < prevInt || rec.intKey == prevInt && String.CompareOrdinal(rec.strKey, prevStr) < 0);
prevStr = rec.strKey;
prevInt = rec.intKey;
n += 1;
}
Assert.That(n == nRecords);
Console.Out.WriteLine("Elapsed time for iterating through " + (nRecords * 2) + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = 1999;
for (i2 = 0; i2 < nRecords; i2++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
int intKey = (int) (SupportClass.URShift(key, 32));
string strKey = Convert.ToString((int) key);
Record rec = (Record) root.Get(new Key(new System.Object[]{(System.Int32) intKey, strKey}));
Assert.That(rec != null && rec.intKey == intKey && rec.strKey.Equals(strKey));
Assert.That(root.Contains(rec));
root.Remove(rec);
rec.Deallocate();
}
Assert.That(!root.GetEnumerator().MoveNext());
Assert.That(!root.GetEnumerator(null, null, IndexSortOrder.Descent).MoveNext());
Assert.That(!root.GetEnumerator(null, null, IndexSortOrder.Ascent).MoveNext());
Console.Out.WriteLine("Elapsed time for deleting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
db.Close();
//.........这里部分代码省略.........
示例7: Main
//.........这里部分代码省略.........
}
}
db.Open("testcidx.dbs", pagePoolSize);
#if USE_GENERICS
MultiFieldIndex<Record> root = (MultiFieldIndex<Record>)db.Root;
if (root == null) {
root = db.CreateFieldIndex<Record>(new string[]{"intKey", "strKey"}, true);
#else
FieldIndex root = (FieldIndex)db.Root;
if (root == null) {
root = db.CreateFieldIndex(typeof(Record), new string[]{"intKey", "strKey"}, true);
#endif
db.Root = root;
}
DateTime start = DateTime.Now;
long key = 1999;
for (i = 0; i < nRecords; i++) {
Record rec = new Record();
key = (3141592621L*key + 2718281829L) % 1000000007L;
rec.intKey = (int)((ulong)key >> 32);
rec.strKey = Convert.ToString((int)key);
root.Put(rec);
}
db.Commit();
Console.WriteLine("Elapsed time for inserting " + nRecords + " records: " + (DateTime.Now - start));
start = DateTime.Now;
key = 1999;
int minKey = Int32.MaxValue;
int maxKey = Int32.MinValue;
for (i = 0; i < nRecords; i++) {
key = (3141592621L*key + 2718281829L) % 1000000007L;
int intKey = (int)((ulong)key >> 32);
String strKey = Convert.ToString((int)key);
#if USE_GENERICS
Record rec = root.Get(new Key(new Object[]{intKey, strKey}));
#else
Record rec = (Record)root.Get(new Key(new Object[]{intKey, strKey}));
#endif
Debug.Assert(rec != null && rec.intKey == intKey && rec.strKey.Equals(strKey));
if (intKey < minKey) {
minKey = intKey;
}
if (intKey > maxKey) {
maxKey = intKey;
}
}
Console.WriteLine("Elapsed time for performing " + nRecords + " index searches: " + (DateTime.Now - start));
start = DateTime.Now;
int n = 0;
string prevStr = "";
int prevInt = minKey;
foreach (Record rec in root.Range(new Key(minKey, ""),
new Key(maxKey+1, "???"),
IterationOrder.AscentOrder))
{
Debug.Assert(rec.intKey > prevInt || rec.intKey == prevInt && rec.strKey.CompareTo(prevStr) > 0);
prevStr = rec.strKey;
prevInt = rec.intKey;
n += 1;
}
Debug.Assert(n == nRecords);
n = 0;
prevInt = maxKey+1;
foreach (Record rec in root.Range(new Key(minKey, "", false),
new Key(maxKey+1, "???", false),
IterationOrder.DescentOrder))
{
Debug.Assert(rec.intKey < prevInt || rec.intKey == prevInt && rec.strKey.CompareTo(prevStr) < 0);
prevStr = rec.strKey;
prevInt = rec.intKey;
n += 1;
}
Debug.Assert(n == nRecords);
Console.WriteLine("Elapsed time for iterating through " + (nRecords*2) + " records: " + (DateTime.Now - start));
start = DateTime.Now;
key = 1999;
for (i = 0; i < nRecords; i++) {
key = (3141592621L*key + 2718281829L) % 1000000007L;
int intKey = (int)((ulong)key >> 32);
String strKey = Convert.ToString((int)key);
#if USE_GENERICS
Record rec = root.Get(new Key(new Object[]{intKey, strKey}));
#else
Record rec = (Record)root.Get(new Key(new Object[]{intKey, strKey}));
#endif
Debug.Assert(rec != null && rec.intKey == intKey && rec.strKey.Equals(strKey));
Debug.Assert(root.Contains(rec));
root.Remove(rec);
rec.Deallocate();
}
Debug.Assert(!root.GetEnumerator().MoveNext());
Debug.Assert(!root.Reverse().GetEnumerator().MoveNext());
Console.WriteLine("Elapsed time for deleting " + nRecords + " records: " + (DateTime.Now - start));
db.Close();
}
}
示例8: Main
public static void Main(string[] args)
{
Storage db = StorageFactory.Instance.CreateStorage();
db.Open("testidx2.dbs", pagePoolSize);
Indices root = (Indices) db.GetRoot();
if (root == null)
{
root = new Indices();
root.strIndex = db.CreateSortedCollection(new StrRecordComparator(), true);
root.intIndex = db.CreateSortedCollection(new IntRecordComparator(), true);
db.SetRoot(root);
}
SortedCollection intIndex = root.intIndex;
SortedCollection strIndex = root.strIndex;
long start = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
long key = 1999;
int i;
for (i = 0; i < nRecords; i++)
{
Record rec = new Record();
key = (3141592621L * key + 2718281829L) % 1000000007L;
rec.intKey = key;
rec.strKey = System.Convert.ToString(key);
intIndex.Add(rec);
strIndex.Add(rec);
}
db.Commit();
db.Gc();
Console.Out.WriteLine("Elapsed time for inserting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = 1999;
for (i = 0; i < nRecords; i++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
Record rec1 = (Record) intIndex.Get((long) key);
Record rec2 = (Record) strIndex.Get(Convert.ToString(key));
Assert.That(rec1 != null && rec1 == rec2);
}
Console.Out.WriteLine("Elapsed time for performing " + nRecords * 2 + " index searches: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
System.Collections.IEnumerator iterator = intIndex.GetEnumerator();
key = Int64.MinValue;
for (i = 0; iterator.MoveNext(); i++)
{
Record rec = (Record) iterator.Current;
Assert.That(rec.intKey >= key);
key = rec.intKey;
}
Assert.That(i == nRecords);
iterator = strIndex.GetEnumerator();
string strKey = "";
for (i = 0; iterator.MoveNext(); i++)
{
Record rec = (Record) iterator.Current;
Assert.That(String.CompareOrdinal(rec.strKey, strKey) >= 0);
strKey = rec.strKey;
}
Assert.That(i == nRecords);
Console.Out.WriteLine("Elapsed time for iterating through " + (nRecords * 2) + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
System.Collections.Hashtable map = db.GetMemoryDump();
iterator = map.Values.GetEnumerator();
Console.Out.WriteLine("Memory usage");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
while (iterator.MoveNext())
{
MemoryUsage usage = (MemoryUsage) iterator.Current;
System.Console.Out.WriteLine(" " + usage.cls.FullName + ": instances=" + usage.nInstances + ", total size=" + usage.totalSize + ", allocated size=" + usage.allocatedSize);
}
System.Console.Out.WriteLine("Elapsed time for memory dump: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = 1999;
for (i = 0; i < nRecords; i++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
Record rec = (Record) intIndex.Get((long) key);
intIndex.Remove(rec);
strIndex.Remove(rec);
rec.Deallocate();
}
Assert.That(!intIndex.GetEnumerator().MoveNext());
Assert.That(!strIndex.GetEnumerator().MoveNext());
Assert.That(!intIndex.GetEnumerator(null, null).MoveNext());
Assert.That(!strIndex.GetEnumerator(null, null).MoveNext());
Console.Out.WriteLine("Elapsed time for deleting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
db.Close();
}
示例9: Main
public static void Main(string[] args)
{
Storage db = StorageFactory.Instance.CreateStorage();
db.Open("testmod.dbs", pagePoolSize);
Indices root = (Indices) db.GetRoot();
if (root == null)
{
root = new Indices();
root.strIndex = db.CreateIndex(typeof(string), true);
root.intIndex = db.CreateIndex(typeof(long), true);
db.SetRoot(root);
}
Index intIndex = root.intIndex;
Index strIndex = root.strIndex;
long start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
long key = 1999;
int i;
for (i = 0; i < nRecords; i++)
{
Record rec = new Record();
key = (3141592621L * key + 2718281829L) % 1000000007L;
rec.intKey = key;
rec.strKey = Convert.ToString(key);
intIndex.Put(new Key(rec.intKey), rec);
strIndex.Put(new Key(rec.strKey), rec);
}
db.Commit();
Console.Out.WriteLine("Elapsed time for inserting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
for (int j = 0; j < nIterations; j++)
{
key = 1999;
for (i = 0; i < nRecords; i++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
Record rec = (Record) intIndex.Get(new Key(key));
rec.strKey = reverseString(rec.strKey);
if ((i & 255) == 0)
{
rec.Store();
}
else
{
rec.Modify();
}
}
Console.Out.WriteLine("Iteration " + j);
db.Commit();
}
Console.Out.WriteLine("Elapsed time for performing " + nRecords * nIterations + " updates: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = 1999;
for (i = 0; i < nRecords; i++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
Record rec1 = (Record) intIndex.Get(new Key(key));
Record rec2 = (Record) strIndex.Get(new Key(Convert.ToString(key)));
Assert.That(rec1 != null && rec1 == rec2);
}
Console.Out.WriteLine("Elapsed time for performing " + nRecords * 2 + " index searches: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
key = 1999;
for (i = 0; i < nRecords; i++)
{
key = (3141592621L * key + 2718281829L) % 1000000007L;
Record rec = (Record) intIndex.Get(new Key(key));
intIndex.Remove(new Key(key));
strIndex.Remove(new Key(Convert.ToString(key)), rec);
rec.Deallocate();
}
Console.Out.WriteLine("Elapsed time for deleting " + nRecords + " records: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
db.Close();
}