public class ClobAccessTest extends JDBCPerfTestCase
These tests are intended to detect Clob performance regressions. Before committing a patch that might change the Clob performance characteristics, first run these tests on a clean build and then with the patch applied. The results can only be compared when both runs are done on the same machine.
The results are time taken to execute the test. Lower duration is better
(improvement). Currently the results are printed to standard out. There is
one exception, which is testConcurrency
. For this test, the
throughput is printed and it will always run for a fixed amount of time.
The tests are written with two axis in mind: read-only vs update and small vs large. These axis were chosen based on the Clob implementation at the time. In the context of this test, small means the Clob is represented as a string by the Derby store and large means the Clob is represtend as a stream into the Derby store. When a Clob is modified, an in-memory or on disk temporary copy is created. The performance of these temporary representations are tested with the tests that modify the Clob content.
System properties controlling test behavior:
NOTE: Currently there are no tests for the client driver (network) or for encrypted Clobs.
Modifier and Type | Field and Description |
---|---|
private static boolean |
disableConcurrencyTest |
private static boolean |
disableLargeClobs |
private static boolean |
disableSmallClobs |
private static int |
largeClobSizeMB |
private static int |
MAX_BSIZE
Maximum buffer size to use.
|
private static java.lang.String |
runLargeClobTests
A list of one or more tests to be run.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
ClobAccessTest(java.lang.String name,
int iterations,
int repeats)
Instantiates a new test that will be run the specified number of
iterations and repeated as specified.
|
Modifier and Type | Method and Description |
---|---|
private void |
fetchPieceByPiece(boolean modifyClob)
Fetches a "large" Clob piece by piece using getSubString.
|
private static void |
initializeClobData(java.sql.Statement stmt)
Generates test data.
|
void |
initializeConnection(java.sql.Connection conn)
Set autocommit to false by default.
|
static junit.framework.Test |
suite() |
void |
testConcurrency()
Runs a test using multiple threads.
|
void |
testFetchLargeClobOneByOneChar() |
void |
testFetchLargeClobOneByOneCharBaseline()
Fetches a single Clob and reads it char by char, but utilizing a
buffered stream to get a lower time bound on the read operation.
|
void |
testFetchLargeClobOneByOneCharModified() |
void |
testFetchLargeClobPieceByPiece()
Fetches a "large" Clob piece by piece using getSubString.
|
void |
testFetchLargeClobPieceByPieceBackwards()
Tests that repositioning within the current internal character buffer is
cheap.
|
void |
testFetchLargeClobPieceByPieceModified()
Fetches a "large" Clob piece by piece using getSubString.
|
void |
testFetchLargeClobs() |
void |
testFetchLargeClobsModified() |
void |
testFetchLargeClobWithStream() |
void |
testFetchSmallClobs()
Fetches a number of small Clobs, getting the content using getSubString.
|
void |
testFetchSmallClobsInaccurateLength()
Fetches a number of small Clobs, getting the content using getSubString.
|
void |
testLargeClobGetLength()
Tests if the Clob length is cached.
|
void |
testLargeClobGetLengthModified()
Tests if the Clob length is cached.
|
void |
testLargeClobTruncateLengthMinusOne()
Tests the speed of transferring data from the store to local temporary
storage as part of the truncate operation.
|
void |
testModifySmallClobs()
Test fetching the content after adding a single character at the end.
|
runBareOverridable, runTest
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, setName, setUp, toString
private static final boolean disableSmallClobs
private static final boolean disableLargeClobs
private static final boolean disableConcurrencyTest
private static final java.lang.String runLargeClobTests
private static final int largeClobSizeMB
private static final int MAX_BSIZE
public ClobAccessTest(java.lang.String name, int iterations, int repeats)
name
- name of the test to instantiateiterations
- number of iterations per repetitionrepeats
- number of repetitionspublic void initializeConnection(java.sql.Connection conn) throws java.sql.SQLException
initializeConnection
in class BaseJDBCTestCase
conn
- Connection to be intializedjava.sql.SQLException
- Error setting the initial state.public static junit.framework.Test suite()
public void testFetchSmallClobs() throws java.sql.SQLException
The exact length of the clob is used when getting the string.
java.sql.SQLException
public void testFetchSmallClobsInaccurateLength() throws java.sql.SQLException
A too long length of the clob is used when getting the string.
java.sql.SQLException
public void testModifySmallClobs() throws java.sql.SQLException
java.sql.SQLException
public void testFetchLargeClobs() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testFetchLargeClobsModified() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testFetchLargeClobOneByOneCharBaseline() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testFetchLargeClobOneByOneChar() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testFetchLargeClobOneByOneCharModified() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testFetchLargeClobPieceByPieceBackwards() throws java.io.IOException, java.sql.SQLException
Note that the positions used in this test have been chosen based on the internal buffer size (8KB), which is an implementation detail.
java.sql.SQLException
- if the test failsjava.io.IOException
public void testFetchLargeClobPieceByPiece() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testFetchLargeClobPieceByPieceModified() throws java.io.IOException, java.sql.SQLException
The Clob is modified before fetched to create a temporary Clob representation in memory / on disk.
java.io.IOException
java.sql.SQLException
private void fetchPieceByPiece(boolean modifyClob) throws java.io.IOException, java.sql.SQLException
modifyClob
- whether to modify the Clob before fetching it
(determines the internal Derby Clob representation)java.io.IOException
java.sql.SQLException
public void testFetchLargeClobWithStream() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testLargeClobGetLength() throws java.sql.SQLException
java.sql.SQLException
public void testLargeClobGetLengthModified() throws java.sql.SQLException
java.sql.SQLException
public void testLargeClobTruncateLengthMinusOne() throws java.sql.SQLException
java.sql.SQLException
public void testConcurrency() throws java.lang.InterruptedException, java.sql.SQLException
This test intends to detect problems with small Clobs and general problems with concurrency.
NOTE: To produce more reliable numbers, please run the performance client independently outside this JUnit test framework. Performance also suffers greatly with SANE builds.
java.lang.InterruptedException
java.sql.SQLException
private static void initializeClobData(java.sql.Statement stmt) throws java.sql.SQLException
java.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.