0

Webテストを作成しました。

その中で私はファイルへの書き込みを追加しました。

上記のWebテストのみを実行する5人の仮想ユーザーでloadtestを作成しました。

Graph view私には5つあったことがわかりますUsers load

最後に、ファイルに書き込まれた1行だけが表示されます。

特別な方法で分布を定義する必要がありますか?

仮想ユーザー数を設定するだけで十分だと思いました。いいえ?

ところで、ロードテストがすべての実行で正確に10分間実行される原因は何ですか?

10分に制限したのを覚えていません

これは私のテストコードです:

public class Settings_CacheExplosion:WebTest {// private static readonly ILog activityLog = LogManager.GetLogger( "Activity");

    private static int _ctidsCounter { get; set; }

    public static int CtidsCounter
    {
        get
        {
            if (_ctidsCounter == 2000)
            {
                _ctidsCounter = 1000;
            }
            return _ctidsCounter++;
        }
        set
        {
            _ctidsCounter = value;
        }
    }

    public Settings_CacheExplosion()
    {
        this.PreAuthenticate = true;

        CtidsCounter = 1000;

        //log4net.Config.XmlConfigurator.Configure();
    }


    public override IEnumerator<WebTestRequest> GetRequestEnumerator()
    {
        WebTestRequest request1 = new WebTestRequest("http://clientservice.mam.qasite-services.com/settings");

        request1.Method = "POST";

        Debug.WriteLine(string.Format("ctid={0}", CtidsCounter));

        request1.QueryStringParameters.Add("ctid", CtidsCounter.ToString(), false, false);
        StringHttpBody request1Body = new StringHttpBody();
        request1Body.ContentType = "";
        request1Body.InsertByteOrderMark = false;
        request1Body.BodyString = "";
        request1.Body = request1Body;

        string path = @"Settings_CacheExplosion_log.txt";
        // This text is added only once to the file. 
        if (!File.Exists(path))
        {
            // Create a file to write to. 
            using (StreamWriter sw = File.CreateText(path))
            {
                sw.WriteLine(string.Format("ctid={0}", CtidsCounter));
            }
        }

        // This text is always added, making the file longer over time 
        // if it is not deleted. 
        using (StreamWriter sw = File.AppendText(path))
        {
            sw.WriteLine(string.Format("ctid={0}", CtidsCounter));
        }   


        yield return request1;
        request1 = null;
    }
}
4

1 に答える 1

0

書き込み方法が既存のエントリを上書きしていないことを確認してください。ファイルにすでにテキストがある場合は、追加オプションを使用する必要があります。

于 2012-11-06T07:55:37.330 に答える