Giter Club home page Giter Club logo

Comments (2)

bkiers avatar bkiers commented on September 21, 2024

Thanks for the detailed report @realiteer! I'll have a closer look.

from liqp.

bkiers avatar bkiers commented on September 21, 2024

I'm currently the porting the ANTLR3 grammar to the newer v4 version, and this is now what I get with the newer v4 version of ANTLR:

import liqp.nodes.LNode;
import liqp.tags.Tag;
import org.codehaus.plexus.util.StringUtils;
import org.junit.Test;
import com.google.common.base.Stopwatch;

public class Demo {

    @Test
    public void testCustomTags() {

        Tag.registerTag(new Tag("snippet") {
            @Override
            public Object render(TemplateContext context, LNode... nodes) {
                return "NADA";
            }
        });

        final Stopwatch stopwatch = new Stopwatch();

        for (int n = 1; n < 60; n++) {
            final String content = StringUtils.repeat("{% snippet \"face\" %}", n);

            stopwatch.start();
            Template.parse(content);
            stopwatch.stop();
            System.out.printf("script size=%s, tags=%s -> %s milliseconds\n", content.length(), n, stopwatch.elapsedMillis());
            stopwatch.reset();
        }
    }
}

output:

script size=20, tags=1 -> 278 milliseconds
script size=40, tags=2 -> 8 milliseconds
script size=60, tags=3 -> 3 milliseconds
script size=80, tags=4 -> 3 milliseconds
script size=100, tags=5 -> 4 milliseconds
script size=120, tags=6 -> 4 milliseconds
script size=140, tags=7 -> 5 milliseconds
script size=160, tags=8 -> 5 milliseconds
script size=180, tags=9 -> 5 milliseconds
script size=200, tags=10 -> 4 milliseconds
script size=220, tags=11 -> 3 milliseconds
script size=240, tags=12 -> 5 milliseconds
script size=260, tags=13 -> 4 milliseconds
script size=280, tags=14 -> 4 milliseconds
script size=300, tags=15 -> 9 milliseconds
script size=320, tags=16 -> 5 milliseconds
script size=340, tags=17 -> 6 milliseconds
script size=360, tags=18 -> 6 milliseconds
script size=380, tags=19 -> 6 milliseconds
script size=400, tags=20 -> 6 milliseconds
script size=420, tags=21 -> 9 milliseconds
script size=440, tags=22 -> 15 milliseconds
script size=460, tags=23 -> 12 milliseconds
script size=480, tags=24 -> 12 milliseconds
script size=500, tags=25 -> 9 milliseconds
script size=520, tags=26 -> 14 milliseconds
script size=540, tags=27 -> 10 milliseconds
script size=560, tags=28 -> 7 milliseconds
script size=580, tags=29 -> 10 milliseconds
script size=600, tags=30 -> 27 milliseconds
script size=620, tags=31 -> 17 milliseconds
script size=640, tags=32 -> 8 milliseconds
script size=660, tags=33 -> 16 milliseconds
script size=680, tags=34 -> 9 milliseconds
script size=700, tags=35 -> 18 milliseconds
script size=720, tags=36 -> 13 milliseconds
script size=740, tags=37 -> 13 milliseconds
script size=760, tags=38 -> 14 milliseconds
script size=780, tags=39 -> 15 milliseconds
script size=800, tags=40 -> 23 milliseconds
script size=820, tags=41 -> 19 milliseconds
script size=840, tags=42 -> 19 milliseconds
script size=860, tags=43 -> 25 milliseconds
script size=880, tags=44 -> 20 milliseconds
script size=900, tags=45 -> 27 milliseconds
script size=920, tags=46 -> 20 milliseconds
script size=940, tags=47 -> 20 milliseconds
script size=960, tags=48 -> 19 milliseconds
script size=980, tags=49 -> 24 milliseconds
script size=1000, tags=50 -> 26 milliseconds
script size=1020, tags=51 -> 25 milliseconds
script size=1040, tags=52 -> 20 milliseconds
script size=1060, tags=53 -> 22 milliseconds
script size=1080, tags=54 -> 20 milliseconds
script size=1100, tags=55 -> 19 milliseconds
script size=1120, tags=56 -> 17 milliseconds
script size=1140, tags=57 -> 12 milliseconds
script size=1160, tags=58 -> 16 milliseconds
script size=1180, tags=59 -> 13 milliseconds

from liqp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.