mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Batch-enabled perf. tests
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@23237 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -155,7 +155,8 @@ public class FileFolderPerformanceTester extends TestCase
|
|||||||
final int threadCount,
|
final int threadCount,
|
||||||
final boolean randomOrder,
|
final boolean randomOrder,
|
||||||
final int folderCount,
|
final int folderCount,
|
||||||
final int fileCount,
|
final int batchCount,
|
||||||
|
final int filesPerBatch,
|
||||||
final double[] dumpPoints)
|
final double[] dumpPoints)
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<NodeRef[]> createFoldersCallback = new RetryingTransactionCallback<NodeRef[]>()
|
RetryingTransactionCallback<NodeRef[]> createFoldersCallback = new RetryingTransactionCallback<NodeRef[]>()
|
||||||
@@ -188,13 +189,13 @@ public class FileFolderPerformanceTester extends TestCase
|
|||||||
// progress around the folders until they have been populated
|
// progress around the folders until they have been populated
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
int nextDumpNumber = 0;
|
int nextDumpNumber = 0;
|
||||||
for (int i = 0; i < fileCount; i++)
|
for (int i = 0; i < batchCount; i++)
|
||||||
{
|
{
|
||||||
// must we dump results
|
// must we dump results
|
||||||
double completedCount = (double) i;
|
double completedCount = (double) i;
|
||||||
double nextDumpCount = (dumpPoints == null || dumpPoints.length == 0 || nextDumpNumber >= dumpPoints.length)
|
double nextDumpCount = (dumpPoints == null || dumpPoints.length == 0 || nextDumpNumber >= dumpPoints.length)
|
||||||
? -1.0
|
? -1.0
|
||||||
: (double) fileCount * dumpPoints[nextDumpNumber];
|
: (double) batchCount * dumpPoints[nextDumpNumber];
|
||||||
if ((nextDumpCount - 0.5) < completedCount && completedCount < (nextDumpCount + 0.5))
|
if ((nextDumpCount - 0.5) < completedCount && completedCount < (nextDumpCount + 0.5))
|
||||||
{
|
{
|
||||||
dumpResults(i);
|
dumpResults(i);
|
||||||
@@ -210,36 +211,39 @@ public class FileFolderPerformanceTester extends TestCase
|
|||||||
for (int j = 0; j < folders.length; j++)
|
for (int j = 0; j < folders.length; j++)
|
||||||
{
|
{
|
||||||
final NodeRef folderRef = folders[j];
|
final NodeRef folderRef = folders[j];
|
||||||
RetryingTransactionCallback<FileInfo> createFileCallback = new RetryingTransactionCallback<FileInfo>()
|
RetryingTransactionCallback<Void> createFileCallback = new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
public FileInfo execute() throws Exception
|
public Void execute() throws Exception
|
||||||
{
|
{
|
||||||
FileInfo fileInfo = fileFolderService.create(
|
for (int i = 0; i < filesPerBatch; i++)
|
||||||
folderRef,
|
{
|
||||||
GUID.generate(),
|
FileInfo fileInfo = fileFolderService.create(
|
||||||
ContentModel.TYPE_CONTENT);
|
folderRef,
|
||||||
NodeRef nodeRef = fileInfo.getNodeRef();
|
GUID.generate(),
|
||||||
// write the content
|
ContentModel.TYPE_CONTENT);
|
||||||
ContentWriter writer = fileFolderService.getWriter(nodeRef);
|
NodeRef nodeRef = fileInfo.getNodeRef();
|
||||||
writer.putContent(dataFile);
|
// write the content
|
||||||
|
ContentWriter writer = fileFolderService.getWriter(nodeRef);
|
||||||
|
writer.putContent(dataFile);
|
||||||
|
}
|
||||||
// done
|
// done
|
||||||
return fileInfo;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
retryingTransactionHelper.doInTransaction(createFileCallback);
|
retryingTransactionHelper.doInTransaction(createFileCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dumpResults(fileCount);
|
dumpResults(batchCount);
|
||||||
}
|
}
|
||||||
private void dumpResults(int currentFileCount)
|
private void dumpResults(int currentBatchCount)
|
||||||
{
|
{
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
long time = (end - start);
|
long time = (end - start);
|
||||||
double average = (double) time / (double) (folderCount * currentFileCount);
|
double average = (double) time / (double) (folderCount * currentBatchCount * filesPerBatch);
|
||||||
double percentComplete = (double) currentFileCount / (double) fileCount * 100.0;
|
double percentComplete = (double) currentBatchCount / (double) batchCount * 100.0;
|
||||||
logger.debug("\n" +
|
logger.debug("\n" +
|
||||||
"[" + Thread.currentThread().getName() + "] \n" +
|
"[" + Thread.currentThread().getName() + "] \n" +
|
||||||
" Created " + currentFileCount + " files in each of " + folderCount +
|
" Created " + (currentBatchCount*filesPerBatch) + " files in each of " + folderCount +
|
||||||
" folders (" + (randomOrder ? "shuffled" : "in order") + "): \n" +
|
" folders (" + (randomOrder ? "shuffled" : "in order") + "): \n" +
|
||||||
" Progress: " + String.format("%9.2f", percentComplete) + " percent complete \n" +
|
" Progress: " + String.format("%9.2f", percentComplete) + " percent complete \n" +
|
||||||
" Average: " + String.format("%10.2f", average) + " ms per file \n" +
|
" Average: " + String.format("%10.2f", average) + " ms per file \n" +
|
||||||
@@ -250,10 +254,12 @@ public class FileFolderPerformanceTester extends TestCase
|
|||||||
// kick off the required number of threads
|
// kick off the required number of threads
|
||||||
logger.debug("\n" +
|
logger.debug("\n" +
|
||||||
"Starting " + threadCount +
|
"Starting " + threadCount +
|
||||||
" threads loading " + fileCount +
|
" threads loading " + (batchCount * filesPerBatch) +
|
||||||
" files in each of " + folderCount +
|
" files in each of " + folderCount +
|
||||||
" folders (" +
|
" folders (" +
|
||||||
(randomOrder ? "shuffled" : "in order") + ").");
|
(randomOrder ? "shuffled" : "in order") +
|
||||||
|
(filesPerBatch > 1 ? (" and " + filesPerBatch + " files per txn") : "") +
|
||||||
|
").");
|
||||||
ThreadGroup threadGroup = new ThreadGroup(getName());
|
ThreadGroup threadGroup = new ThreadGroup(getName());
|
||||||
Thread[] threads = new Thread[threadCount];
|
Thread[] threads = new Thread[threadCount];
|
||||||
for (int i = 0; i < threadCount; i++)
|
for (int i = 0; i < threadCount; i++)
|
||||||
@@ -384,6 +390,7 @@ public class FileFolderPerformanceTester extends TestCase
|
|||||||
true,
|
true,
|
||||||
10,
|
10,
|
||||||
100,
|
100,
|
||||||
|
20,
|
||||||
new double[] {0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90});
|
new double[] {0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90});
|
||||||
}
|
}
|
||||||
// public void test_1_ordered_1_50000() throws Exception
|
// public void test_1_ordered_1_50000() throws Exception
|
||||||
|
Reference in New Issue
Block a user