예제 #1
0
    public void _7_2_GetJob1000byLoop(Disquuun disquuun)
    {
        WaitUntil("_7_2_GetJob1000byLoop", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var addingJobCount = 1000 * loadLevel;
        var queueId        = Guid.NewGuid().ToString();

        var addedCount = 0;

        for (var i = 0; i < addingJobCount; i++)
        {
            disquuun.AddJob(queueId, new byte[10]).Async(
                (command, data) => {
                lock (_7_2_GetJob1000byLoopLockObject) addedCount++;
            }
                );
        }

        WaitUntil("_7_2_GetJob1000byLoop", () => (addedCount == addingJobCount), 5);

        var gotJobDataIds = new List <string>();

        var w = new Stopwatch();

        w.Start();

        disquuun.GetJob(new string[] { queueId }).Loop(
            (command, data) => {
            lock (_7_2_GetJob1000byLoopLockObject) {
                var jobDatas = DisquuunDeserializer.GetJob(data);
                var jobIds   = jobDatas.Select(j => j.jobId).ToList();
                gotJobDataIds.AddRange(jobIds);

                if (gotJobDataIds.Count == addingJobCount)
                {
                    w.Stop();
                    return(false);
                }
                return(true);
            }
        }
            );

        WaitUntil("_7_2_GetJob1000byLoop 1", () => (gotJobDataIds.Count == addingJobCount), 20);
        WaitUntil("_7_2_GetJob1000byLoop 2", () => (0 < disquuun.AvailableSocketNum()), 1);

        TestLogger.Log("_7_2_GetJob1000byLoop w:" + w.ElapsedMilliseconds + " tick:" + w.ElapsedTicks);

        var fastackedCount = 0;

        disquuun.FastAck(gotJobDataIds.ToArray()).Async(
            (c, data) => {
            fastackedCount = DisquuunDeserializer.FastAck(data);
        }
            );

        WaitUntil("_7_2_GetJob1000byLoop 3", () => (addingJobCount == fastackedCount), 10);
    }
예제 #2
0
    public long _8_2_0_GetJob1000byPipeline(Disquuun disquuun)
    {
        WaitUntil("_8_2_0_GetJob1000byPipeline 0", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var addingJobCount = 1000 * ratio;

        var queueId = Guid.NewGuid().ToString();

        var addedCount = 0;

        for (var i = 0; i < addingJobCount; i++)
        {
            disquuun.Pipeline(disquuun.AddJob(queueId, data_10));
        }
        disquuun.Pipeline().Execute(
            (command, data) =>
        {
            lock (_8_2_GetJob1000byLoopLockObject) addedCount++;
        }
            );

        WaitUntil("_8_2_0_GetJob1000byPipeline 1", () => (addedCount == addingJobCount), 5);

        var gotJobDataIds = new List <string>();

        var w = new Stopwatch();

        w.Start();

        for (var i = 0; i < addingJobCount; i++)
        {
            disquuun.Pipeline(disquuun.GetJob(new string[] { queueId }, "count", addingJobCount));
        }
        disquuun.Pipeline().Execute(
            (command, data) =>
        {
            lock (_8_2_0_GetJob1000byPipelineObject)
            {
                var jobDatas = DisquuunDeserializer.GetJob(data);
                var jobIds   = jobDatas.Select(j => j.jobId).ToList();
                gotJobDataIds.AddRange(jobIds);

                if (gotJobDataIds.Count == addingJobCount)
                {
                    w.Stop();
                }
            }
        }
            );

        WaitUntil("_8_2_0_GetJob1000byPipeline 2", () => (gotJobDataIds.Count == addingJobCount), 30);
        WaitUntil("_8_2_0_GetJob1000byPipeline 3", () => (0 < disquuun.AvailableSocketNum()), 1);

        var fastackedCount = 0;

        disquuun.FastAck(gotJobDataIds.ToArray()).Async(
            (c, data) =>
        {
            fastackedCount = DisquuunDeserializer.FastAck(data);
        }
            );

        WaitUntil("_8_2_0_GetJob1000byPipeline 4", () => (addingJobCount == fastackedCount), 10);

        return(w.ElapsedMilliseconds);
    }