|
1) Alright it looks like it should be doing it sequentially, otherwise Random.NextDouble could fail, no method in System.Random is threadsafe.
But it should barely take any time at all.
2) Documents... well. Take Amdahl's_law for example, in which P is the proportion of the program that has been made parallel. P would be zero, so you'd get the limit 1 / (1 - 0 + 0/n) where n goes to infinity. So as you can see, the answer is 1, independent of n, meaning: no benefit at all. But of course we knew that that already, since we made no improvement.
3?) I see no good reason for this to be slow, it should be blazingly fast - it's only generating a bunch of random numbers and sending them over right?
|
|
|
|
|
Thanks harold,
1.
"otherwise Random.NextDouble could fail, no method in System.Random is threadsafe." -- I agree it is not thread safe, but I disagree since it is not thread safe, web service will do sequentially. Since each time I creat a new instance of Random object. You can check my code. Any comments?
2.
"Alright it looks like it should be doing it sequentially" -- how do you prove it? My current confusion is, web service has to do sequentially or could do in parallel?
regards,
George
|
|
|
|
|
1) doh yes, sorry, I just woke up
2) you can easily prove it informally by measuring the difference between doing some simultaneous calls vs some sequential calls - if there is no difference (or if the parallel calls took longer) than there are only 2 possible cases:
1: the simultaneous calls were handled sequentially.
2: the simultaneous calls were so short that the overhead of doing them simultaneously was as big as or bigger than the benefit.
You can, of course, test which case it is. Just make the method that is called a good bit longer (say, generate 10k random numbers, then return the last one). If it benefits from threading then it was case 2, otherwise case 1.
|
|
|
|
|
Thanks harold,
1.
I did the following test and I think the web service should work simultaneously.
Here is my new code at server side, and I add an additional Sleep.
I think if working sequentially, it will take 5 * 1000 seconds to complete all jobs (10 threads and each thread get 100 random number), but in my testing experience, it takes about 55 seconds.
Does it prove web service works simultaneously? Any comments?
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public double HelloWorld()
{
Thread.Sleep(500);
return new Random().NextDouble();
}
}
2.
Could you reproduce my issue? I want to know whether it is my environment issue if you could not reproduce it.
3.
If you could reproduce, any ideas to improve performance?
regards,
George
|
|
|
|
|
1) it would take 1000 * 500 miliseconds = 500 seconds if it were sequentially. Which is more than 55 seconds, so, by RAA, it is proven that it wasn't purely sequentially.
Now that's a real breakthrough - it means the threading works but the task (without the sleep) is too short.
2) well, not directly. But it works like that without webservers being involved as well.
3) The threading will help when you let the web method do something useful.
|
|
|
|
|
Thanks harold,
1.
"well, not directly. But it works like that without webservers being involved as well." -- confused. Especially what do you mean "without webservers being involved"? There is web server, since I run it as web service and IIS hosts it.
2.
"The threading will help when you let the web method do something useful." -- confused about what you mean. Could you describe something more?
regards,
George
|
|
|
|
|
1 just means that I tested without using a webserver
2 means that new Random().NextDouble() does not take enough time to be worth multithreading it in this case
|
|
|
|
|
My understanding is that a web service has only one process at a time, so all requests have to queue up anyway.
|
|
|
|
|
Thanks PIEBALDconsult!
1.
"web service has only one process at a time" -- at client side or server side, do you mean?
2.
"web service has only one process at a time" -- any documents to prove your points? I am very interested to learn from it.
regards,
George
|
|
|
|
|
1. Server side, the service doesn't run on the client.
2. If I did, I would have given a more authoritative answer.
|
|
|
|
|
Thanks PIEBALDconsult!
If the bottleneck is "web service has only one process at a time", how do you prove it or show some related documents?
regards,
George
|
|
|
|
|
I don't know, I'm not a Web expert, I'm hoping someone with more knowledge will step in and answer that for both of us.
You could possibly create a Web Service with two methods, one that sleeps for a minute and one that doesn't.
Make a request to the one that sleeps, and while it's sleeping make a request to the other and see whether or not it waits for the sleeping one to complete.
|
|
|
|
|
Thanks PIEBALDconsult,
I am not sure what you are going to prove. In your scenario, you have web service (say sleep) and another web service (say sleepless).
If we call on a thread from client side, first call sleep web service, then call sleepless web service, since it is synchronous call in one thread from client, the client will definitely wait for the sleep web service to complete the return results until call the second sleepless web service.
Please correct me if I am wrong in understanding your points. I am confused what you are going to prove -- so obvious results.
regards,
George
|
|
|
|
|
Not two services and one client, one service and two clients.
|
|
|
|
|
how to i read MAC Address in C#?
|
|
|
|
|
|
Hi,
thanks for your reply.
i have another question. is it possible using mac address for software lock?
i want to my porogram runs only on spesified PC.
Regards,
|
|
|
|
|
Sure. But you have to program this on your own...
|
|
|
|
|
Ohh tanx for soooooon reply
and the my big project is here, i don't know how to do this:
I have a measurement device that measure and sends a data update string to the PC once a millisecond, so you can see what's happening in real-time. I would like to let authorized people see my data via the web in roughly real time using a web browser such as Internet explorer. I have an internet connection with valid IP address that whole of day is connected.
My idea so far, is to divide the problem into originator (my PC putting data on database) and clients (pc's logging into my computer via web browser to see latest data).
Originator:
I thought I would use SQL database to save average measured data into the database every one seconds.
Clients:
This has to log in, see designed GUI, select charts, table and reports via menu.
I am very keen to hear any suggestions
Does you know how I can do this?
|
|
|
|
|
Hmm sounds familiar. Didn't you post the question before in another forum?
Anyway trying to use a database on a server is good idea. You could build an ASP.NET application, that will be deployed on the server. The user has to logon to the page to see the results stored in your database. Advantage of this solution is that ASP.NET offers a lot of build-in controls like charts, reports and datagridviews and you client only needs a browser for this.
|
|
|
|
|
Ohumm
Yes i posted it
Have you any sample or article similar to my project?
|
|
|
|
|
where is Org ????
i'm amator
|
|
|
|
|
Sry, I didn't get this. What do you mean?
|
|
|
|
|
Bad idea. A MAC address can be spoofed. Or there could be multiple NICs in the machine at any given time, What if there is no NIC in the machine? If you're trying to identify the machine software is installed on, you may as well give up, because there is simply no reliable way to do it that will work every time on every machine.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
the machine hardware configuration that i need to install my software on it, consist one ethernet port indispensable and maybe one wireless adaptor (wireless is optional).
|
|
|
|