コード例 #1
0
        public void SchedulerLoadPerformaceTest()
        {
            RedisScheduler scheduler = new RedisScheduler("localhost", "");
            ISpider spider = new DefaultSpider("test", new Site());
            var start = DateTime.Now;
            for (int i = 0; i < 40000; i++)
            {
                scheduler.Push(new Request("http://www.a.com/" + i, 1, null));
            }

            var end = DateTime.Now;
            double seconds = (end - start).TotalSeconds;
            scheduler.Clear();

            var start1 = DateTime.Now;
            HashSet<Request> list = new HashSet<Request>();
            for (int i = 0; i < 40000; i++)
            {
                list.Add(new Request("http://www.a.com/" + i, 1, null));
            }
            scheduler.Load(list);
            var end1 = DateTime.Now;
            double seconds1 = (end1 - start1).TotalSeconds;
            Assert.IsTrue(seconds1 < seconds);
        }
コード例 #2
0
        public void RedisTest()
        {
            RedisScheduler redisScheduler = new RedisScheduler("localhost", "");

            ISpider spider = new DefaultSpider();
            redisScheduler.Clear();

            Request request = new Request("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/", 1, null);
            request.PutExtra("1", "2");
            redisScheduler.Push(request);
            Request result = redisScheduler.Poll();
            Assert.AreEqual("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/", result.Url.ToString());
            Request result1 = redisScheduler.Poll();
            Assert.IsNull(result1);
            redisScheduler.Dispose();

            redisScheduler.Clear();
        }