Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to test Firebase and C# performace
var msgSent = 1;
var errors = 0;
Action<string,string,string,string> sendMessage =
(app,token, area, message)=>
{
ThreadPool.QueueUserWorkItem((o)=>
{
var url = "https://{0}.firebaseio.com/{1}.json?auth={2}".format(app, area, token);
var now = DateTime.Now. TimeOfDay; //DateTime.Now.ToShortTimeString();
var data = "\"[{0}] {1}\"".format(now, message.replace("\"", "'"));
if (url.POST(data).inValid())
errors++;
msgSent++;
});
};
var _app = "tm-admin-test";
var _authToken = "11uXXuQHpzhrG2LzV1DNu17tAAAAAAAABBBBBBBB";
var _area = "debugMsg";
var _message = "Let's try 1000";
var start = DateTime.Now;
var msgToSend = 1000;
for(int i=1 ; i <= msgToSend ; i++)
sendMessage(_app, _authToken, _area, "[{0}/{1}] {2}".format(i,msgToSend, _message));
while (msgSent < (msgToSend))
{
50.sleep();
if ((DateTime.Now - start).TotalMilliseconds > 30000)
return "Execution timeout";
}
return "sent {0} messages (with {1} errors) in {2}".format(msgSent,errors, (DateTime.Now - start).TotalMilliseconds);
//using System.Threading;
//using TeamMentor.CoreLib;
//O2Ref:TeamMentor.CoreLib.dll
/*int workerThreads;
int completionPortThreads;
System.Threading.ThreadPool.SetMaxThreads(2000,2000);
System.Threading.ThreadPool. GetMaxThreads(out workerThreads, out completionPortThreads);
return "workerThreads: {0} completionPortThreads:{1}".format( workerThreads, completionPortThreads);*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.