public static void main(String[] args) throws Exception
{
Cache cache;
CacheFactory cacheFactory;
Class factoryClass;
String factoryClassName = FifoCacheFactory.class.getName();
int size = 100;
int ttl = 2000;
int threads = 1; // running worker threads
int cycles = 100; // cycles per thread
int gpc = 5; // gets per cycle
int ppc = 5; // puts per cycle
Thrasher thrasher = null;
for (int i = 0; i < args.length; i++)
{
LOG.message("arg[ " + i + " ] = " + args[i]);
}
for (int i = 0; i < args.length; i++)
{
if ("-factory".equalsIgnoreCase(args[i]))
{
factoryClassName = args[++i];
}
if ("-size".equalsIgnoreCase(args[i]))
{
size = Integer.parseInt(args[++i]);
}
if ("-ttl".equalsIgnoreCase(args[i]))
{
ttl = Integer.parseInt(args[++i]);
}
if ("-threads".equalsIgnoreCase(args[i]))
{
threads = Integer.parseInt(args[++i]);
}
if ("-cycles".equalsIgnoreCase(args[i]))
{
cycles = Integer.parseInt(args[++i]);
}
if ("-gpc".equalsIgnoreCase(args[i]))
{
gpc = Integer.parseInt(args[++i]);
}
if ("-ppc".equalsIgnoreCase(args[i]))
{
ppc = Integer.parseInt(args[++i]);
}
}
factoryClass = Class.forName(factoryClassName);
cacheFactory = (CacheFactory) factoryClass.newInstance();
cache = cacheFactory.newInstance("thrasher", ttl, size);
thrasher = new Thrasher(cache, threads);
thrasher.thrash();
}