Search in sources :

Example 1 with Serializer

use of org.apache.xml.security.encryption.Serializer in project testcases by coheigea.

the class PerformanceMemoryTest method testRunFirstOutboundEncryptionMemoryPerformance.

@Test
public void testRunFirstOutboundEncryptionMemoryPerformance() throws Exception {
    System.out.println("Testing Outbound Encryption Memory Performance");
    FileWriter outEncryptionSamplesWriter = new FileWriter("target/encryptionOutMemorySamples.txt", false);
    Serializer documentSerializer = new DocumentSerializer();
    Serializer staxSerializer = new StaxSerializer();
    Serializer transformSerializer = new TransformSerializer();
    for (int i = 1; i <= runs; i++) {
        System.out.println("Run " + i);
        File file = generateLargeXMLFile(i * xmlResizeFactor);
        int startTagCount = countXMLStartTags(file);
        outEncryptionSamplesWriter.write("" + startTagCount);
        long startMem = getUsedMemory();
        MemorySamplerThread mst = new MemorySamplerThread(startMem);
        Thread thread = new Thread(mst);
        thread.setPriority(9);
        thread.start();
        File encryptedFile = doDOMEncryptionOutbound(file, startTagCount, documentSerializer);
        mst.setStop(true);
        thread.join();
        outEncryptionSamplesWriter.write(" " + mst.getMaxUsedMemory());
        startMem = getUsedMemory();
        mst = new MemorySamplerThread(startMem);
        thread = new Thread(mst);
        thread.setPriority(9);
        thread.start();
        doDOMEncryptionOutbound(file, startTagCount, staxSerializer);
        mst.setStop(true);
        thread.join();
        outEncryptionSamplesWriter.write(" " + mst.getMaxUsedMemory());
        startMem = getUsedMemory();
        mst = new MemorySamplerThread(startMem);
        thread = new Thread(mst);
        thread.setPriority(9);
        thread.start();
        doDOMEncryptionOutbound(file, startTagCount, transformSerializer);
        mst.setStop(true);
        thread.join();
        outEncryptionSamplesWriter.write(" " + mst.getMaxUsedMemory());
        encryptedFiles.put(startTagCount, encryptedFile);
        outEncryptionSamplesWriter.write("\n");
    }
    outEncryptionSamplesWriter.close();
}
Also used : StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) DocumentSerializer(org.apache.xml.security.encryption.DocumentSerializer) FileWriter(java.io.FileWriter) File(java.io.File) DocumentSerializer(org.apache.xml.security.encryption.DocumentSerializer) StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) Serializer(org.apache.xml.security.encryption.Serializer) TransformSerializer(org.apache.xml.security.encryption.TransformSerializer) TransformSerializer(org.apache.xml.security.encryption.TransformSerializer) Test(org.junit.Test)

Example 2 with Serializer

use of org.apache.xml.security.encryption.Serializer in project testcases by coheigea.

the class EncryptionSerializerBenchmark method decryptionStaxSerializer.

@Benchmark
@Fork(1)
@Warmup(iterations = 5)
@Measurement(iterations = 20)
public void decryptionStaxSerializer() throws Exception {
    Serializer serializer = new StaxSerializer();
    Document encryptedDoc = doEncryption(null);
    doDecryption(encryptedDoc, serializer);
}
Also used : StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) Document(org.w3c.dom.Document) StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) Serializer(org.apache.xml.security.encryption.Serializer) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Fork(org.openjdk.jmh.annotations.Fork) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 3 with Serializer

use of org.apache.xml.security.encryption.Serializer in project testcases by coheigea.

the class PerformanceMemoryTest method testRunSecondInboundDecryptionMemoryPerformance.

@Test
public void testRunSecondInboundDecryptionMemoryPerformance() throws Exception {
    System.out.println("Testing Inbound Decryption Memory Performance");
    FileWriter inEncryptionSamplesWriter = new FileWriter("target/encryptionInMemorySamples.txt", false);
    Serializer documentSerializer = new DocumentSerializer();
    Serializer staxSerializer = new StaxSerializer();
    Serializer transformSerializer = new TransformSerializer();
    int run = 1;
    Iterator<Map.Entry<Integer, File>> mapIterator = encryptedFiles.entrySet().iterator();
    while (mapIterator.hasNext()) {
        Map.Entry<Integer, File> entry = mapIterator.next();
        System.out.println("Run " + (run++));
        File file = entry.getValue();
        Integer startTagCount = entry.getKey();
        inEncryptionSamplesWriter.write("" + startTagCount);
        long startMem = getUsedMemory();
        MemorySamplerThread mst = new MemorySamplerThread(startMem);
        Thread thread = new Thread(mst);
        thread.setPriority(9);
        thread.start();
        doDOMDecryptionInbound(file, startTagCount, documentSerializer);
        mst.setStop(true);
        thread.join();
        inEncryptionSamplesWriter.write(" " + mst.getMaxUsedMemory());
        startMem = getUsedMemory();
        mst = new MemorySamplerThread(startMem);
        thread = new Thread(mst);
        thread.setPriority(9);
        thread.start();
        doDOMDecryptionInbound(file, startTagCount, staxSerializer);
        mst.setStop(true);
        thread.join();
        inEncryptionSamplesWriter.write(" " + mst.getMaxUsedMemory());
        startMem = getUsedMemory();
        mst = new MemorySamplerThread(startMem);
        thread = new Thread(mst);
        thread.setPriority(9);
        thread.start();
        doDOMDecryptionInbound(file, startTagCount, transformSerializer);
        mst.setStop(true);
        thread.join();
        inEncryptionSamplesWriter.write(" " + mst.getMaxUsedMemory());
        inEncryptionSamplesWriter.write("\n");
    }
    inEncryptionSamplesWriter.close();
}
Also used : FileWriter(java.io.FileWriter) TransformSerializer(org.apache.xml.security.encryption.TransformSerializer) StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) DocumentSerializer(org.apache.xml.security.encryption.DocumentSerializer) File(java.io.File) DocumentSerializer(org.apache.xml.security.encryption.DocumentSerializer) StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) Serializer(org.apache.xml.security.encryption.Serializer) TransformSerializer(org.apache.xml.security.encryption.TransformSerializer) Test(org.junit.Test)

Example 4 with Serializer

use of org.apache.xml.security.encryption.Serializer in project testcases by coheigea.

the class PerformanceTimingTest method testRunSecondInboundDecryptionTimePerformance.

@Test
public void testRunSecondInboundDecryptionTimePerformance() throws Exception {
    System.out.println("Testing Inbound Decryption Time Performance");
    FileWriter inEncryptionSamplesWriter = new FileWriter("target/encryptionInTimeSamples.txt", false);
    Serializer documentSerializer = new DocumentSerializer();
    Serializer staxSerializer = new StaxSerializer();
    Serializer transformSerializer = new TransformSerializer();
    int run = 1;
    Iterator<Map.Entry<Integer, File>> mapIterator = encryptedFiles.entrySet().iterator();
    while (mapIterator.hasNext()) {
        Map.Entry<Integer, File> entry = mapIterator.next();
        System.out.println("Run " + (run++));
        File file = entry.getValue();
        Integer startTagCount = entry.getKey();
        inEncryptionSamplesWriter.write("" + startTagCount);
        long start = System.currentTimeMillis();
        doDOMDecryptionInbound(file, startTagCount, documentSerializer);
        inEncryptionSamplesWriter.write(" " + ((System.currentTimeMillis() - start) / 1000.0));
        doGC();
        start = System.currentTimeMillis();
        doDOMDecryptionInbound(file, startTagCount, staxSerializer);
        inEncryptionSamplesWriter.write(" " + ((System.currentTimeMillis() - start) / 1000.0));
        doGC();
        start = System.currentTimeMillis();
        doDOMDecryptionInbound(file, startTagCount, transformSerializer);
        inEncryptionSamplesWriter.write(" " + ((System.currentTimeMillis() - start) / 1000.0));
        doGC();
        inEncryptionSamplesWriter.write("\n");
    }
    inEncryptionSamplesWriter.close();
}
Also used : FileWriter(java.io.FileWriter) TransformSerializer(org.apache.xml.security.encryption.TransformSerializer) StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) DocumentSerializer(org.apache.xml.security.encryption.DocumentSerializer) TreeMap(java.util.TreeMap) Map(java.util.Map) File(java.io.File) DocumentSerializer(org.apache.xml.security.encryption.DocumentSerializer) StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) Serializer(org.apache.xml.security.encryption.Serializer) TransformSerializer(org.apache.xml.security.encryption.TransformSerializer) Test(org.junit.Test)

Example 5 with Serializer

use of org.apache.xml.security.encryption.Serializer in project testcases by coheigea.

the class PerformanceTimingTest method testRunFirstOutboundEncryptionTimePerformance.

@Test
public void testRunFirstOutboundEncryptionTimePerformance() throws Exception {
    System.out.println("Testing Outbound Encryption Time Performance");
    FileWriter outEncryptionSamplesWriter = new FileWriter("target/encryptionOutTimeSamples.txt", false);
    Serializer documentSerializer = new DocumentSerializer();
    Serializer staxSerializer = new StaxSerializer();
    Serializer transformSerializer = new TransformSerializer();
    for (int i = 1; i <= runs; i++) {
        System.out.println("Run " + i);
        File file = generateLargeXMLFile(i * xmlResizeFactor);
        int startTagCount = countXMLStartTags(file);
        outEncryptionSamplesWriter.write("" + startTagCount);
        long start = System.currentTimeMillis();
        File encryptedFile = doDOMEncryptionOutbound(file, startTagCount, documentSerializer);
        outEncryptionSamplesWriter.write(" " + ((System.currentTimeMillis() - start) / 1000.0));
        doGC();
        start = System.currentTimeMillis();
        doDOMEncryptionOutbound(file, startTagCount, staxSerializer);
        outEncryptionSamplesWriter.write(" " + ((System.currentTimeMillis() - start) / 1000.0));
        doGC();
        start = System.currentTimeMillis();
        doDOMEncryptionOutbound(file, startTagCount, transformSerializer);
        outEncryptionSamplesWriter.write(" " + ((System.currentTimeMillis() - start) / 1000.0));
        doGC();
        encryptedFiles.put(startTagCount, encryptedFile);
        outEncryptionSamplesWriter.write("\n");
    }
    outEncryptionSamplesWriter.close();
}
Also used : StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) DocumentSerializer(org.apache.xml.security.encryption.DocumentSerializer) FileWriter(java.io.FileWriter) File(java.io.File) DocumentSerializer(org.apache.xml.security.encryption.DocumentSerializer) StaxSerializer(org.apache.cxf.ws.security.wss4j.StaxSerializer) Serializer(org.apache.xml.security.encryption.Serializer) TransformSerializer(org.apache.xml.security.encryption.TransformSerializer) TransformSerializer(org.apache.xml.security.encryption.TransformSerializer) Test(org.junit.Test)

Aggregations

StaxSerializer (org.apache.cxf.ws.security.wss4j.StaxSerializer)5 Serializer (org.apache.xml.security.encryption.Serializer)5 File (java.io.File)4 FileWriter (java.io.FileWriter)4 DocumentSerializer (org.apache.xml.security.encryption.DocumentSerializer)4 TransformSerializer (org.apache.xml.security.encryption.TransformSerializer)4 Test (org.junit.Test)4 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1 Fork (org.openjdk.jmh.annotations.Fork)1 Measurement (org.openjdk.jmh.annotations.Measurement)1 Warmup (org.openjdk.jmh.annotations.Warmup)1 Document (org.w3c.dom.Document)1