I have a program that after some computation( at leat 5 per second) I get a result for any of them. I want to save these data to corresponding table in data base. My program written with c# and I use entity framework code first and wpf. My program is similar below code:
public struct ResultData{
//Contain some result for example 20 property of string, int and float
}
public class MyProcess
{
public void GetResult(){
//some computation
....
return resultdata;
}
}
public class MainClass{
public MyPorccess porcess;
public ResultData newResultData;
...
//below section occurs 10 per second
{
...
newResultData = process.GetResult;
//save to database
using(sampledatabse db= new sampledatabse()){
...
//add new result to database
db.SaveChanges();
}
....
}
What is best practice for save these result into database with best performance in programs that need save many record per second?
What is least time of for example 10 operation per second into database?
Usage of my ram In current program with save new result into database after get new result, increase ascending.
please help me.
Edit:
I create a concurrentQueue and enqueue new result to it. Then I create a backgroundWorker and inside it I dequeue resultData when ConcurrentQueue.Length is bigger than 0. Then I save this new result to database.
But ram usage is ascending.