本文整理汇总了C#中ODatabase.Query方法的典型用法代码示例。如果您正苦于以下问题:C# ODatabase.Query方法的具体用法?C# ODatabase.Query怎么用?C# ODatabase.Query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ODatabase
的用法示例。
在下文中一共展示了ODatabase.Query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateProperty
public void ShouldCreateProperty()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// prerequisites
database
.Create.Class("TestClass")
.Extends<OVertex>()
.Run();
// Basic Test
foreach (var item in Enum.GetNames(typeof(OType)))
{
database.Create
.Property("_" + item.ToLower(), (OType)Enum.Parse(typeof(OType), item))
.Class("TestClass")
.Run();
}
var document = database.Query(_metadataQuery);
foreach (var item in Enum.GetNames(typeof(OType)))
{
var metadata = document.Find(d => d.GetField<string>("name") == "_" + item.ToLower());
validateMetadata(metadata, (OType)Enum.Parse(typeof(OType), item));
}
// Complex Test
database
.Create
.Property("_embededlist_with_type", OType.EmbeddedList)
.LinkedType(OType.Integer)
.Class("TestClass")
.Run();
database
.Create
.Property("_embededlist_with_class", OType.EmbeddedList)
.LinkedClass("OUser")
.Class("TestClass")
.Run();
document = database.Query(_metadataQuery);
var elwtMetadata = document.Find(d => d.GetField<string>("name") == "_embededlist_with_type");
validateMetadata(elwtMetadata, OType.EmbeddedList);
Assert.AreEqual(OType.Integer, (OType)elwtMetadata.GetField<int>("linkedType"));
var elwcMetadata = document.Find(d => d.GetField<string>("name") == "_embededlist_with_class");
validateMetadata(elwtMetadata, OType.EmbeddedList);
Assert.AreEqual("OUser", elwcMetadata.GetField<string>("linkedClass"));
}
}
}
示例2: ShouldFetchLinkedDocumentsFromSimpleQuery
public void ShouldFetchLinkedDocumentsFromSimpleQuery()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
database.Create.Class("Owner").Extends("V").Run();
database.Create.Class("Computer").Extends("V").Run();
var owner = new ODocument { OClassName = "Owner" };
owner.SetField<String>("name", "Shawn");
owner = database.Create.Vertex(owner).Run();
var computer = new ODocument { OClassName = "Computer" };
computer.SetField<ORID>("owner", owner.ORID);
database.Create.Vertex(computer).Run();
computer = database.Query("SELECT FROM Computer", "*:-1").FirstOrDefault();
Assert.That(database.ClientCache.ContainsKey(computer.GetField<ORID>("owner")));
var document = database.ClientCache[computer.GetField<ORID>("owner")];
Assert.That(document.GetField<string>("name"), Is.EqualTo("Shawn"));
}
}
示例3: CreateDatabaseTestManualy
static void CreateDatabaseTestManualy()
{
using (var server = new OServer("127.0.0.1", 2424, "root", "root"))
{
var created = false;
try
{
created = server.CreateDatabase("TestManualy", ODatabaseType.Document, OStorageType.PLocal);
if (!created)
throw new Exception("Database not created");
var exists = server.DatabaseExist("TestManualy", OStorageType.PLocal);
if (!exists)
throw new Exception("Database not exists");
System.Console.WriteLine("Database created - get server configuration");
var config = server.ConfigList();
foreach (var item in config)
{
System.Console.WriteLine("{0} : {1}",
item.Key, item.Value);
}
System.Console.WriteLine("try connect to the database and query");
OClient.CreateDatabasePool(
"localhost",
2424,
"TestManualy",
ODatabaseType.Graph,
"root",
"root",
10,
"AppConnection"
);
using (var database = new ODatabase("AppConnection"))
{
var documents = database.Query("select from OUser");
foreach (var item in documents)
{
System.Console.WriteLine("Name: {0} Status: {1}",
item.GetField<string>("name"), item.GetField<string>("status"));
}
}
OClient.DropDatabasePool("AppConnection");
}
finally
{
if (created)
server.DropDatabase("TestManualy", OStorageType.PLocal);
}
}
}
示例4: CreateDatabaseTestUsingContext
static void CreateDatabaseTestUsingContext()
{
using (var context = new TestDatabaseContext())
using (var database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
var documents = database.Query("select from OUser");
foreach (var item in documents)
{
System.Console.WriteLine("Name: {0} Status: {1}",
item.GetField<string>("name"), item.GetField<string>("status"));
}
}
}
示例5: ShouldConvertSQLQueryResultsToClass
public void ShouldConvertSQLQueryResultsToClass()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
database.Create.Class<TestVertex>().Run();
database.Create.Vertex(new TestVertex
{
Name = "Shawn",
Age = 37
}).Run();
List<TestVertex> result = database.Query<TestVertex>("SELECT FROM TestVertex");
Assert.That(result[0].Name, Is.EqualTo("Shawn"));
Assert.That(result[0].Age, Is.EqualTo(37));
}
}
示例6: ShouldCreateNonPrimitiveProperties
public void ShouldCreateNonPrimitiveProperties()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
if (!db.Schema.IsClassExist<TestClass>())
{
db.Create.Class<TestClass>().CreateProperties<TestClass>().Run();
var document = db.Query(_metadataQuery);
var SomeListMetadata = document.Find(d => d.GetField<string>("name") == "SomeList");
validateMetadata(SomeListMetadata, OType.EmbeddedList);
var DictionaryMetadata = document.Find(d => d.GetField<string>("name") == "Dictionary");
validateMetadata(DictionaryMetadata, OType.EmbeddedMap);
}
}
}
示例7: TestQuery
static void TestQuery()
{
ODatabase database = new ODatabase(_alias);
//List<ORecord> records = database.Query("select from OGraphVertex where title = \"server 1\"", "*:2");
//List<ORecord> records = database.Query("select [email protected] as inVs, [email protected] as outVs, title from OGraphVertex where @rid = #8:0");
List<ORecord> records = database.Query(
"select " +
" out.in as neighborRIDs," +
//" out.in.type as neighborTypes," +
//" out.in.state as neighborStates," +
" title," +
" @rid" +
" from #8:0"
);
foreach (ORecord record in records)
{
//Ve v = record.To<Ve>();
List<ORID> orids = record.GetField<List<ORID>>("neighborRIDs");
List<string> types = record.GetField<List<string>>("neighborTypes");
List<int> states = record.GetField<List<int>>("neighborStates");
System.Console.WriteLine("{0} - {1} {2} {3}", record.GetField<string>("title"), orids.Count, types.Count, states.Count);
//System.Console.WriteLine(v.Title);
}
/*foreach (ORecord record in database.Query("select from OGraphEdge limit 20", "*:2"))
{
Ed e = record.To<Ed>();
System.Console.WriteLine(e.Label);
}*/
//ORecord rec = database.Command("create vertex OGraphVertex set title = \"whoa\"").ToSingle();
//object foo = database.Command("delete vertex " + rec.ORID.ToString());
}
示例8: using
public void GIVEN___EmployeeArrayType_class_with_common_data_type___WHEN___write_to_orientdb___THEN___should_be_able_to_read()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
var employeeClassName = "EmployeeArrayType";
var clusterid = db.Create.Class(employeeClassName).Run();
var employee = new EmployeeArrayType();
employee.Id = Guid.NewGuid();
employee.Name = new string[2];
employee.Name[0] = "Andrew";
employee.Name[1] = ("Jack");
employee.Age = new int[2];
employee.Age[0] = (1);
employee.Age[1] = (2);
employee.BirthDate = new DateTime[2];
employee.BirthDate[0] = (DateTime.Now);
employee.BirthDate[1] = (DateTime.Now.AddDays(-3));
employee.Childs = new EmployeeCommonType[2];
employee.Childs[0] = (new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.Childs[1] = (new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.FavoriteColor = new Color[2];
employee.FavoriteColor[0] = (Color.Red);
employee.FavoriteColor[1] = (Color.Blue);
employee.Height = new short[2];
employee.Height[0] = (323);
employee.Height[1] = (333);
employee.Ids = new Guid[2];
employee.Ids[0] = (Guid.NewGuid());
employee.Ids[1] = (Guid.NewGuid());
employee.IsMarried = new bool[2];
employee.IsMarried[0] = (true);
employee.IsMarried[1] = (false);
employee.Salary = new decimal[2];
employee.Salary[0] = ((decimal)1234567890.123456789);
employee.Salary[1] = ((decimal)1234567890.123456799);
employee.Tall = new long[2];
employee.Tall[0] = (3233);
employee.Tall[1] = (3234);
employee.YearlyIncome = new double[2];
employee.YearlyIncome[0] = (3233);
employee.YearlyIncome[1] = (1234);
var document = db.Insert<EmployeeArrayType>(employee).Run();
var result = db.Query<EmployeeArrayType>("SELECT * FROM " + employeeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault();
Assert.AreEqual(employee.Id, result.Id);
Assert.AreEqual(employee.Ids[0], result.Ids[0]);
Assert.AreEqual(employee.Ids[1], result.Ids[1]);
Assert.AreEqual(employee.Name[0], result.Name[0]);
Assert.AreEqual(employee.Name[1], result.Name[1]);
Assert.AreEqual(employee.Age[0], result.Age[0]);
Assert.AreEqual(employee.Age[1], result.Age[1]);
Assert.AreEqual(employee.Age[0], result.Age[0]);
Assert.AreEqual(employee.Salary[0], result.Salary[0]);
Assert.AreEqual(employee.Salary[1], result.Salary[1]);
Assert.AreEqual(employee.IsMarried[0], result.IsMarried[0]);
Assert.AreEqual(employee.IsMarried[1], result.IsMarried[1]);
Assert.AreEqual(employee.Childs[0].Id, result.Childs[0].Id);
Assert.AreEqual(employee.Childs[1].Id, result.Childs[1].Id);
Assert.AreEqual(employee.BirthDate[0].ToLongDateString(), result.BirthDate[0].ToLongDateString());
Assert.AreEqual(employee.BirthDate[1].ToLongDateString(), result.BirthDate[1].ToLongDateString());
Assert.AreEqual(employee.YearlyIncome[0], result.YearlyIncome[0]);
Assert.AreEqual(employee.YearlyIncome[1], result.YearlyIncome[1]);
Assert.AreEqual(employee.FavoriteColor[0], result.FavoriteColor[0]);
Assert.AreEqual(employee.FavoriteColor[1], result.FavoriteColor[1]);
Assert.AreEqual(employee.Height[0], result.Height[0]);
Assert.AreEqual(employee.Height[1], result.Height[1]);
Assert.AreEqual(employee.Tall[0], result.Tall[0]);
Assert.AreEqual(employee.Tall[1], result.Tall[1]);
}
}
示例9: using
public void GIVEN___EmployeeDictionaryType_class_with_common_data_type___WHEN___write_to_orientdb___THEN___should_be_able_to_read()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
var employeeClassName = "EmployeeDictionaryType";
var clusterid = db.Create.Class(employeeClassName).Run();
var employee = new EmployeeDictionaryType();
employee.Id = Guid.NewGuid();
employee.Name = new Dictionary<string, string>();
employee.Name.Add("Andrew", "Andrew");
employee.Name.Add("Jack", "Jack");
employee.Ids = new Dictionary<Guid, Guid>();
employee.Ids.Add(Guid.NewGuid(), Guid.NewGuid());
employee.Ids.Add(Guid.NewGuid(), Guid.NewGuid());
employee.Age = new Dictionary<int, int>();
employee.Age.Add(1, 2);
employee.Age.Add(2, 4);
employee.Height = new Dictionary<short, short>();
employee.Height.Add(1, 2);
employee.Height.Add(2, 4);
employee.Tall = new Dictionary<long, long>();
employee.Tall.Add(1234567890123456789, 987654321098765432);
employee.Tall.Add(987654321098765432, 1234567890123456789);
employee.Childs = new Dictionary<int, EmployeeCommonType>();
employee.Childs.Add(1, new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.Childs.Add(2, new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.FavoriteColor = new Dictionary<Color, Color>();
employee.FavoriteColor.Add(Color.Red, Color.Red);
employee.FavoriteColor.Add(Color.Blue, Color.Blue);
var document = db.Insert(employee).Into(employeeClassName).Run();
var result = db.Query<EmployeeDictionaryType>("SELECT * FROM " + employeeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault();
Assert.Equal(employee.Id, result.Id);
Assert.True(result.Name.ContainsKey("Jack"));
Assert.True(result.Name.ContainsKey("Andrew"));
Assert.Equal(employee.Name["Jack"], result.Name["Jack"]);
Assert.Equal(employee.Name["Andrew"], result.Name["Andrew"]);
Assert.True(result.Ids.ContainsKey(employee.Ids.Keys.ToArray()[0]));
Assert.True(result.Ids.ContainsKey(employee.Ids.Keys.ToArray()[1]));
Assert.Equal(employee.Ids[employee.Ids.Keys.ToArray()[0]], result.Ids[employee.Ids.Keys.ToArray()[0]]);
Assert.Equal(employee.Ids[employee.Ids.Keys.ToArray()[1]], result.Ids[employee.Ids.Keys.ToArray()[1]]);
Assert.True(result.Age.ContainsKey(1));
Assert.True(result.Age.ContainsKey(2));
Assert.Equal(employee.Age[1], result.Age[1]);
Assert.Equal(employee.Age[2], result.Age[2]);
Assert.True(result.Height.ContainsKey(employee.Height.Keys.ToArray()[0]));
Assert.True(result.Height.ContainsKey(employee.Height.Keys.ToArray()[1]));
Assert.Equal(employee.Height[employee.Height.Keys.ToArray()[0]], result.Height[employee.Height.Keys.ToArray()[0]]);
Assert.Equal(employee.Height[employee.Height.Keys.ToArray()[1]], result.Height[employee.Height.Keys.ToArray()[1]]);
Assert.True(result.Tall.ContainsKey(employee.Tall.Keys.ToArray()[0]));
Assert.True(result.Tall.ContainsKey(employee.Tall.Keys.ToArray()[1]));
Assert.Equal(employee.Tall[employee.Tall.Keys.ToArray()[0]], result.Tall[employee.Tall.Keys.ToArray()[0]]);
Assert.Equal(employee.Tall[employee.Tall.Keys.ToArray()[1]], result.Tall[employee.Tall.Keys.ToArray()[1]]);
Assert.Equal(employee.Childs[1].Id, result.Childs[1].Id);
Assert.Equal(employee.Childs[2].Id, result.Childs[2].Id);
Assert.True(result.FavoriteColor.ContainsKey(Color.Red));
Assert.True(result.FavoriteColor.ContainsKey(Color.Blue));
Assert.Equal(employee.FavoriteColor[Color.Red], result.FavoriteColor[Color.Red]);
Assert.Equal(employee.FavoriteColor[Color.Blue], result.FavoriteColor[Color.Blue]);
}
}
示例10: CreateDatabasePoolTest
static void CreateDatabasePoolTest()
{
OClient.CreateDatabasePool(
"localhost",
2424,
"GratefulDeadConcerts",
ODatabaseType.Graph,
"root",
"root",
10,
"AppConnection"
);
using (var database = new ODatabase("AppConnection"))
{
var documents = database.Query("select from v");
foreach (var item in documents)
{
System.Console.WriteLine("Name: {0} Type: {1}",
item.GetField<string>("name"), item.GetField<string>("type"));
}
}
OClient.DropDatabasePool("AppConnection");
}
示例11: ConnectionPoolTest
static void ConnectionPoolTest()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
database
.Create.Class("Person")
.Extends<OVertex>()
.Run();
database
.Create.Class("Spouse")
.Extends<OVertex>()
.Run();
ODocument person1 = database
.Create.Vertex("Person")
.Set("Name", "Johny")
.Run();
ODocument spouse1 = database
.Create.Vertex("Spouse")
.Set("Name", "Mary")
.Run();
ODocument spouse2 = database
.Create.Vertex("Spouse")
.Set("Name", "Julia")
.Run();
// TODO: check what happens in command execution
ODocument edge1 = database
.Create.Edge<OEdge>()
.From(person1)
.To(spouse1)
.Run();
ODocument edge2 = database
.Create.Edge<OEdge>()
.From(person1)
.To(spouse2)
.Run();
List<ODocument> docs = database.Query("select from Person");
}
bool exit = false;
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
database
.Create.Class("TestClass")
.Extends<OVertex>()
.Run();
database
.Create.Vertex("TestClass")
.Set("foo", "foo string value 1")
.Set("bar", 123)
.Run();
database
.Create.Vertex("TestClass")
.Set("foo", "foo string value 2")
.Set("bar", 1233)
.Run();
}
while (!exit)
{
System.Console.WriteLine(
"Current pool size: {0} @ {1} : {2}",
OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias),
DateTime.Now.ToString(),
Query().Count
);
string line = System.Console.ReadLine();
if (line.Equals("exit"))
{
exit = true;
}
}
}
}
示例12: ShouldFetchDocumentsConnectedByEdges
public void ShouldFetchDocumentsConnectedByEdges()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
{
using (ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
// Need to set this
database.Command("alter database custom useLightweightEdges=true");
database.Create.Class("House").Extends("V").Run();
database.Create.Class("Person").Extends("V").Run();
database.Create.Class("Owns").Extends("E").Run();
var house = new ODocument { OClassName = "House" };
database.Create.Vertex(house).Run();
var person = new ODocument { OClassName = "Person" };
person.SetField("name", "Shawn");
database.Create.Vertex(person).Run();
var person1 = new ODocument { OClassName = "Person" };
person1.SetField("name", "Roman");
database.Create.Vertex(person1).Run();
database.Create.Edge("Owns").From(person).To(house).Run();
database.Create.Edge("Owns").From(person1).To(house).Run();
house = database.Query("select from House", "*:-1").FirstOrDefault();
Assert.That(house != null);
Assert.That(database.ClientCache.Count(), Is.EqualTo(2), "client cache should contain two records");
}
}
}
示例13: TestQuery
static void TestQuery()
{
using (ODatabase database = new ODatabase(_hostname, _port, _databaseName, ODatabaseType.Document, _username, _password))
{
TestClass obj = database.LoadRecord<TestClass>(new ORID(6, 0));
foreach (string s in database.Query("select from cluster:ouser"))
{
Console.WriteLine(s);
}
}
}
示例14: ShouldInsertClassWithEmbededList
public void ShouldInsertClassWithEmbededList()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
var employeeListTypeClassName = "EmployeeListType";
var clusterid = db.Create.Class(employeeListTypeClassName).Run();
var employee = new EmployeeListType();
employee.Id = Guid.NewGuid();
employee.Name = new List<string>();
employee.Name.Add("Andrew");
employee.Name.Add("Jack");
employee.Age = new List<int>();
employee.Age.Add(1);
employee.Age.Add(2);
employee.BirthDate = new List<DateTime>();
employee.BirthDate.Add(DateTime.Now);
employee.BirthDate.Add(DateTime.Now.AddDays(-3));
employee.Childs = new List<EmployeeCommonType>();
employee.Childs.Add(new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.Childs.Add(new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.FavoriteColor = new List<Color>();
employee.FavoriteColor.Add(Color.Red);
employee.FavoriteColor.Add(Color.Blue);
employee.Height = new List<short>();
employee.Height.Add(323);
employee.Height.Add(333);
employee.Ids = new List<Guid>();
employee.Ids.Add(Guid.NewGuid());
employee.Ids.Add(Guid.NewGuid());
employee.IsMarried = new List<bool>();
employee.IsMarried.Add(true);
employee.IsMarried.Add(false);
employee.Salary = new List<decimal>();
employee.Salary.Add((decimal)1234567890.123456789);
employee.Salary.Add((decimal)1234567890.123456799);
employee.Tall = new List<long>();
employee.Tall.Add(3233);
employee.Tall.Add(3234);
employee.YearlyIncome = new List<double>();
employee.YearlyIncome.Add(3233);
employee.YearlyIncome.Add(1234);
var document = db.Insert<EmployeeListType>(employee).Run();
var result = db.Query<EmployeeListType>("SELECT * FROM " + employeeListTypeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault();
Assert.Equal(employee.Id, result.Id);
Assert.Equal(employee.Ids[0], result.Ids[0]);
Assert.Equal(employee.Ids[1], result.Ids[1]);
Assert.Equal(employee.Name[0], result.Name[0]);
Assert.Equal(employee.Name[1], result.Name[1]);
Assert.Equal(employee.Age[0], result.Age[0]);
Assert.Equal(employee.Age[1], result.Age[1]);
Assert.Equal(employee.Age[0], result.Age[0]);
Assert.Equal(employee.Salary[0], result.Salary[0]);
Assert.Equal(employee.Salary[1], result.Salary[1]);
Assert.Equal(employee.IsMarried[0], result.IsMarried[0]);
Assert.Equal(employee.IsMarried[1], result.IsMarried[1]);
// Error happen here.
Assert.Equal(employee.Childs[0].Id, result.Childs[0].Id);
Assert.Equal(employee.Childs[1].Id, result.Childs[1].Id);
Assert.Equal(employee.BirthDate[0].ToLongDateString(), result.BirthDate[0].ToLongDateString());
Assert.Equal(employee.BirthDate[1].ToLongDateString(), result.BirthDate[1].ToLongDateString());
Assert.Equal(employee.YearlyIncome[0], result.YearlyIncome[0]);
Assert.Equal(employee.YearlyIncome[1], result.YearlyIncome[1]);
Assert.Equal(employee.FavoriteColor[0], result.FavoriteColor[0]);
Assert.Equal(employee.FavoriteColor[1], result.FavoriteColor[1]);
Assert.Equal(employee.Height[0], result.Height[0]);
Assert.Equal(employee.Height[1], result.Height[1]);
Assert.Equal(employee.Tall[0], result.Tall[0]);
Assert.Equal(employee.Tall[1], result.Tall[1]);
}
}
示例15: Do
static long Do()
{
DateTime start = DateTime.Now;
bool running = true;
long tps = 0;
do
{
ODatabase database = new ODatabase(_alias);
//List<ORecord> result = database.Query("select name from OGraphVertex where in[0].label = 'followed_by' and in[0].out.name = 'JAM'");
//List<ORecord> result = database.Query("select from OGraphVertex limit 20");
List<ORecord> result = database.Query("select from OGraphEdge limit 20");
database.Close();
tps++;
TimeSpan dif = DateTime.Now - start;
if (dif.TotalMilliseconds > 1000)
{
running = false;
}
}
while (running);
return tps;
}