{{groovy}}
String wikiName = "test";
int testNumber = 1000;
resultsPage = xwiki.getDocument("WikiStressTestCode", "InsideGroovyResults");
resultsPage.setContent("");
resultsPage.save();
int wikiNumber = 1;
while(wikiNumber <= testNumber) {
begin = System.currentTimeMillis();
String wikiId = String.format("%s%s", wikiName, wikiNumber);
if(services.wiki.exists(wikiId)) {
wiki = services.wiki.getById(wikiId);
} else {
wiki = services.wiki.createWiki(wikiId, wikiId, "xwiki:XWiki.Admin", true);
}
if(wiki) {
String wikiPrettyName = String.format("Wiki %s #%s", wikiName, wikiNumber);
wiki.setPrettyName(wikiPrettyName);
String wikiDescription = String.format("Wiki %s #%s created for the stress test", wikiName, wikiNumber);
wiki.setDescription(wikiDescription);
services.wiki.saveDescriptor(wiki);
}
wikiNumber = wikiNumber + 1;
end = System.currentTimeMillis();
String time = String.format("%d", end-begin);
resultsPageContent = resultsPage.getContent();
resultsPage.setContent(String.format("%s\n%s", resultsPageContent, time));
resultsPage.save();
}
{{/groovy}}