-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up the get attribute expression a little bit
- Loading branch information
Showing
5 changed files
with
103 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/main/java/com/mitchellbosecke/pebble/template/ClassAttributeCacheEntry.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/com/mitchellbosecke/pebble/BenchmarkTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.mitchellbosecke.pebble; | ||
|
||
import java.io.IOException; | ||
import java.io.StringWriter; | ||
import java.io.Writer; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import com.mitchellbosecke.pebble.error.PebbleException; | ||
import com.mitchellbosecke.pebble.loader.Loader; | ||
import com.mitchellbosecke.pebble.loader.StringLoader; | ||
import com.mitchellbosecke.pebble.template.PebbleTemplate; | ||
|
||
@Ignore | ||
public class BenchmarkTest extends AbstractTest { | ||
|
||
@Test | ||
public void benchmark() throws PebbleException, IOException { | ||
Loader stringLoader = new StringLoader(); | ||
PebbleEngine pebble = new PebbleEngine(stringLoader); | ||
|
||
PebbleTemplate template = pebble.getTemplate("hello {{ object.firstName }} {{ object.lastName }}"); | ||
Map<String, Object> context = new HashMap<>(); | ||
context.put("object", new SimpleObject()); | ||
|
||
Writer writer = new StringWriter(); | ||
int numberOfEvaluations = 1000_000; | ||
|
||
for (int i = 0; i < numberOfEvaluations; i++) { | ||
template.evaluate(writer, context); | ||
} | ||
} | ||
|
||
public class SimpleObject { | ||
public String firstName = "Steve"; | ||
|
||
private String lastName = "Johnson"; | ||
|
||
public String getFirstName(){ | ||
return firstName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters