Last active
August 29, 2015 13:56
-
-
Save DinisCruz-Dev/9229432 to your computer and use it in GitHub Desktop.
Script to test Firebase and C# performace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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