Search in sources :

Example 1 with StringSaveSession

use of org.jabref.logic.exporter.StringSaveSession in project jabref by JabRef.

the class Benchmarks method write.

@Benchmark
public String write() throws Exception {
    BibtexDatabaseWriter<StringSaveSession> databaseWriter = new BibtexDatabaseWriter<>(StringSaveSession::new);
    StringSaveSession saveSession = databaseWriter.savePartOfDatabase(new BibDatabaseContext(database, new MetaData(), new Defaults()), database.getEntries(), new SavePreferences());
    return saveSession.getStringValue();
}
Also used : Defaults(org.jabref.model.Defaults) BibtexDatabaseWriter(org.jabref.logic.exporter.BibtexDatabaseWriter) MetaData(org.jabref.model.metadata.MetaData) SavePreferences(org.jabref.logic.exporter.SavePreferences) StringSaveSession(org.jabref.logic.exporter.StringSaveSession) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 2 with StringSaveSession

use of org.jabref.logic.exporter.StringSaveSession in project jabref by JabRef.

the class Benchmarks method init.

@Setup
public void init() throws Exception {
    Globals.prefs = JabRefPreferences.getInstance();
    Random randomizer = new Random();
    for (int i = 0; i < 1000; i++) {
        BibEntry entry = new BibEntry();
        entry.setCiteKey("id" + i);
        entry.setField("title", "This is my title " + i);
        entry.setField("author", "Firstname Lastname and FirstnameA LastnameA and FirstnameB LastnameB" + i);
        entry.setField("journal", "Journal Title " + i);
        entry.setField("keyword", "testkeyword");
        entry.setField("year", "1" + i);
        entry.setField("rnd", "2" + randomizer.nextInt());
        database.insertEntry(entry);
    }
    BibtexDatabaseWriter<StringSaveSession> databaseWriter = new BibtexDatabaseWriter<>(StringSaveSession::new);
    StringSaveSession saveSession = databaseWriter.savePartOfDatabase(new BibDatabaseContext(database, new MetaData(), new Defaults()), database.getEntries(), new SavePreferences());
    bibtexString = saveSession.getStringValue();
    latexConversionString = "{A} \\textbf{bold} approach {\\it to} ${{\\Sigma}}{\\Delta}$ modulator \\textsuperscript{2} \\$";
    htmlConversionString = "<b>&Ouml;sterreich</b> &#8211; &amp; characters &#x2aa2; <i>italic</i>";
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) Defaults(org.jabref.model.Defaults) Random(java.util.Random) BibtexDatabaseWriter(org.jabref.logic.exporter.BibtexDatabaseWriter) MetaData(org.jabref.model.metadata.MetaData) SavePreferences(org.jabref.logic.exporter.SavePreferences) StringSaveSession(org.jabref.logic.exporter.StringSaveSession) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

BibtexDatabaseWriter (org.jabref.logic.exporter.BibtexDatabaseWriter)2 SavePreferences (org.jabref.logic.exporter.SavePreferences)2 StringSaveSession (org.jabref.logic.exporter.StringSaveSession)2 Defaults (org.jabref.model.Defaults)2 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)2 MetaData (org.jabref.model.metadata.MetaData)2 Random (java.util.Random)1 BibEntry (org.jabref.model.entry.BibEntry)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1 Setup (org.openjdk.jmh.annotations.Setup)1