Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += delegate { _interrupted = true; };

            while (!_interrupted)
            {
                using (var context = new Context(1))
                {
                    var proxyStoreFactory = new ProxyStoreZeroMQFactory(context);

                    var proxyResourceService = proxyStoreFactory.Build();

                    var getProxyResourceRequest = new GetProxyResourceRequest {
                        TargetUrl = "http://www.ticketmaster.com/example"
                    };

                    const int requestsToSend = 1000;

                    DateTime start = DateTime.UtcNow;
                    for (int requestNumber = 0; requestNumber < requestsToSend; requestNumber++)
                    {
                        var resource = proxyResourceService.GetProxyResource(getProxyResourceRequest);

                        ReleaseProxyResourceRequest releaseRequest = new ReleaseProxyResourceRequest()
                        {
                            ProxyResource = resource.ProxyResource
                        };
                        proxyResourceService.ReleaseProxyResource(releaseRequest);
                    }
                    DateTime end = DateTime.UtcNow;

                    Console.WriteLine("{0} took {1}", requestsToSend, end.Subtract(start));
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += delegate { _interrupted = true; };

            while (!_interrupted)
            {
                using (var context = new Context(1))
                {
                    var proxyStoreFactory = new ProxyStoreZeroMQFactory(context);

                    var proxyResourceService = proxyStoreFactory.Build();

                    var getProxyResourceRequest = new GetProxyResourceRequest { TargetUrl = "http://www.ticketmaster.com/example" };

                    const int requestsToSend = 1000;

                    DateTime start = DateTime.UtcNow;
                    for (int requestNumber = 0; requestNumber < requestsToSend; requestNumber++)
                    {
                        var resource = proxyResourceService.GetProxyResource(getProxyResourceRequest);

                        ReleaseProxyResourceRequest releaseRequest = new ReleaseProxyResourceRequest() { ProxyResource = resource.ProxyResource };
                        proxyResourceService.ReleaseProxyResource(releaseRequest);

                    }
                    DateTime end = DateTime.UtcNow;

                    Console.WriteLine("{0} took {1}", requestsToSend, end.Subtract(start));

                }
            }
        }