using System;
using System.Collections.Generic;
using System.Text;
using SimpleLoadTesting;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
//Create a VUManager that will hold all of the VU's, timing info, etc. for one single VirtualUser class that you create.
//We need a DLL or EXE assembly file that contains a class derived from "SimpleLoadTesting.VirtualUser"
SimpleLoadTesting.VUManager vum = new VUManager(@"C:\Downloads\SimpleLoadTesting_1_0_0_0\Sample\bin\Debug\Sample.exe", "Sample.SampleVU");
//Init will make sure the assembly file and the class can be loaded.
if (vum.Init() == false)
{
System.Console.WriteLine("Error loading Assembly file or Class from specified file.");
return;
}
//Each time you call StartUser(# trans) it will create a new user and assign it the next VU number (1,2,...).
//Create 5 VU's and have each one perform 5 transactions/loops/cycles/...
for (int x = 1; x <= 5; x++)
{
vum.StartUser(5);
}
//Wait for them all to finish. When there are no more VU's running we they have all exited/finished.
while (vum.TotalRunningUsers > 0)
{
}
//Print out some timing results. Only basic statistics are available (aka average time).
for (int y = 0; y < vum.GetTimerCount(); y++)
{
System.Console.WriteLine("Timer Name={0} : Average={1}",
vum.GetTimerName(y),
vum.GetTimerAverage(y)
);
}
//Create a 6th VU and have it run for 1 second. Zero transactions means run until it is told to stop.
vum.StartUser(0);
System.Threading.Thread.Sleep(1000);
vum.StopUser(6);
System.Console.WriteLine("Press Enter to exit!");
System.Console.ReadLine();
}
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
using System;
using System.Collections.Generic;
using System.Text;
using SimpleLoadTesting;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
//Create a VUManager that will hold all of the VU's, timing info, etc. for one single VirtualUser class that you create.
//We need a DLL or EXE assembly file that contains a class derived from "SimpleLoadTesting.VirtualUser"
SimpleLoadTesting.VUManager vum = new VUManager(@"C:\Downloads\SimpleLoadTesting_1_0_0_0\Sample\bin\Debug\Sample.exe", "Sample.SampleVU");
//Init will make sure the assembly file and the class can be loaded.
if (vum.Init() == false)
{
System.Console.WriteLine("Error loading Assembly file or Class from specified file.");
return;
}
//Each time you call StartUser(# trans) it will create a new user and assign it the next VU number (1,2,...).
//Create 5 VU's and have each one perform 5 transactions/loops/cycles/...
for (int x = 1; x <= 5; x++)
{
vum.StartUser(5);
}
//Wait for them all to finish. When there are no more VU's running we they have all exited/finished.
while (vum.TotalRunningUsers > 0)
{
}
//Print out some timing results. Only basic statistics are available (aka average time).
for (int y = 0; y < vum.GetTimerCount(); y++)
{
System.Console.WriteLine("Timer Name={0} : Average={1}",
vum.GetTimerName(y),
vum.GetTimerAverage(y)
);
}
//Create a 6th VU and have it run for 1 second. Zero transactions means run until it is told to stop.
vum.StartUser(0);
System.Threading.Thread.Sleep(1000);
vum.StopUser(6);
System.Console.WriteLine("Press Enter to exit!");
System.Console.ReadLine();
}
}
}