Skip to content

Commit

Permalink
gh-47 fix keystore gen
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknow0 committed Jul 6, 2024
1 parent 57d4dea commit b8f88bd
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bench/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cxf_stop=tomcat_stop
mkdir -p out
trap '[[ "$pid" ]] && kill -9 $pid' EXIT

keytool -genkey -alias server -keyalg RSA -validity 365 -keystore store.jks -keypass 123456 -storetype JKS -dname "C=FR"
keytool -genkey -alias server -keyalg RSA -validity 365 -keystore store.jks -keystorepass 123456 -storetype JKS -dname "C=FR"

${1}_start
sleep 10
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package unknow.server.bench;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.openjdk.jmh.annotations.Benchmark;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

public class BenchDocument {
private static final ClassLoader cl = BenchDocument.class.getClassLoader();

@Benchmark
public void xmlBean() throws XmlException, IOException {
XmlObject o;
try (InputStream is = cl.getResourceAsStream("complex.xml")) {
o = XmlObject.Factory.parse(is);
}

o.save(DUMP);
}

private static final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
private static final TransformerFactory tranformer = TransformerFactory.newInstance();

@Benchmark
public void document() throws SAXException, IOException, ParserConfigurationException, TransformerConfigurationException, TransformerException {
Document o;
try (InputStream is = cl.getResourceAsStream("complex.xml")) {
o = docFactory.newDocumentBuilder().parse(is);
}

tranformer.newTransformer().transform(new DOMSource(o), new StreamResult(DUMP));
}

private static final OutputStream DUMP = new OutputStream() {
@Override
public void write(int b) throws IOException { // OK
}

@Override
public void write(byte[] b) throws IOException { // OK
}

@Override
public void write(byte[] b, int off, int len) throws IOException { // OK
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import jakarta.xml.bind.JAXBException;
import unknow.server.http.test.xml.Complex;

public class XmlBench {
private static final ClassLoader cl = XmlBench.class.getClassLoader();
public class BenchJaxb {
private static final ClassLoader cl = BenchJaxb.class.getClassLoader();
private static final Class<?>[] CLASS = { Complex.class };
static final JAXBContext UNKNOW;
static final JAXBContext JAXB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void main(String[] args) throws Exception {
Options o = new OptionsBuilder().forks(1).measurementIterations(10).verbosity(VerboseMode.NORMAL).warmupIterations(5).build();

try (PrintStream w = args.length > 0 ? new PrintStream(Files.newOutputStream(Paths.get(args[0])), false, StandardCharsets.UTF_8) : System.out) {
for (Class<?> c : Arrays.asList(XmlBench.class)) {
for (Class<?> c : Arrays.asList(BenchJaxb.class, BenchDocument.class)) {
w.println(c.getSimpleName());
w.println("```");
Collection<RunResult> result = new Runner(new OptionsBuilder().parent(o).include(c.getName()).build()).run();
Expand Down

0 comments on commit b8f88bd

Please sign in to comment.