// Path: url/src/main/java/com/danisola/restify/url/RestParserFactory.java
// public static RestParser parser(String pattern, VarType... types) {
//     checkPattern(pattern);
// 
//     final int numTypes = types.length;
//     ParsedUrl parsedUrl = parseUrl(pattern);
//     StringBuilder sb = new StringBuilder();
// 
//     // Processing path
//     int typesIndex = processMarkers(types, 0, sb, parsedUrl.getPath());
//     Pattern pathPattern = Pattern.compile(sb.toString());
//     VarType[] pathTypes = Arrays.copyOfRange(types, 0, typesIndex);
// 
//     // Processing parameters
//     List<NameValuePair> params = parsedUrl.getParameters();
//     ParamVar[] paramVars = new ParamVar[params.size()];
//     int paramVarCounter = 0;
//     for (int i = 0; i < paramVars.length; i++) {
//         NameValuePair pair = params.get(i);
// 
//         int newTypesIndex = processMarkers(types, typesIndex, sb, pair.getValue());
//         checkState(newTypesIndex > typesIndex, "Parameter '%s' has no variables in its value", pair.getName());
// 
//         VarType[] paramTypes = Arrays.copyOfRange(types, typesIndex, newTypesIndex);
//         Pattern paramValuePattern = Pattern.compile(sb.toString());
//         paramVars[i] = new ParamVar(pair.getName(), paramTypes, paramValuePattern);
//         paramVarCounter += newTypesIndex - typesIndex;
//         typesIndex = newTypesIndex;
//     }
// 
//     final int numVars = pathTypes.length + paramVarCounter;
//     checkState(numVars == numTypes, "The number of variables (%d) and types (%d) do not match", numVars, numTypes);
//     return new RestParser(pathPattern, pathTypes, paramVars, numTypes);
// }
// 
// Path: url/src/main/java/com/danisola/restify/url/types/IntVar.java
// public static IntVar intVar(String id) {
//     return new IntVar(id);
// }
// 
// Path: url/src/main/java/com/danisola/restify/url/types/StrVar.java
// public static StrVar strVar(String id) {
//     return new StrVar(id);
// }


import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
import static com.danisola.restify.url.RestParserFactory.parser;
import static com.danisola.restify.url.types.IntVar.intVar;
import static com.danisola.restify.url.types.StrVar.strVar;
package com.danisola.restify.url;



public class UrlRestifyBenchmark extends SimpleBenchmark {

    public RestParser timeCreatingParser(int reps) {
        RestParser parser = null;
        for (int i = 0; i < reps; i++) {
            parser = parser("/leagues/{}/teams/{}/players?age={}", strVar("leagueId"), strVar("teamId"),
                    intVar("playerAge"));
        }
        return parser;
    }

    public String timeParsing(int reps) {
// Path: url/src/main/java/com/danisola/restify/url/RestParserFactory.java
// public static RestParser parser(String pattern, VarType... types) {
//     checkPattern(pattern);
// 
//     final int numTypes = types.length;
//     ParsedUrl parsedUrl = parseUrl(pattern);
//     StringBuilder sb = new StringBuilder();
// 
//     // Processing path
//     int typesIndex = processMarkers(types, 0, sb, parsedUrl.getPath());
//     Pattern pathPattern = Pattern.compile(sb.toString());
//     VarType[] pathTypes = Arrays.copyOfRange(types, 0, typesIndex);
// 
//     // Processing parameters
//     List<NameValuePair> params = parsedUrl.getParameters();
//     ParamVar[] paramVars = new ParamVar[params.size()];
//     int paramVarCounter = 0;
//     for (int i = 0; i < paramVars.length; i++) {
//         NameValuePair pair = params.get(i);
// 
//         int newTypesIndex = processMarkers(types, typesIndex, sb, pair.getValue());
//         checkState(newTypesIndex > typesIndex, "Parameter '%s' has no variables in its value", pair.getName());
// 
//         VarType[] paramTypes = Arrays.copyOfRange(types, typesIndex, newTypesIndex);
//         Pattern paramValuePattern = Pattern.compile(sb.toString());
//         paramVars[i] = new ParamVar(pair.getName(), paramTypes, paramValuePattern);
//         paramVarCounter += newTypesIndex - typesIndex;
//         typesIndex = newTypesIndex;
//     }
// 
//     final int numVars = pathTypes.length + paramVarCounter;
//     checkState(numVars == numTypes, "The number of variables (%d) and types (%d) do not match", numVars, numTypes);
//     return new RestParser(pathPattern, pathTypes, paramVars, numTypes);
// }
// 
// Path: url/src/main/java/com/danisola/restify/url/types/IntVar.java
// public static IntVar intVar(String id) {
//     return new IntVar(id);
// }
// 
// Path: url/src/main/java/com/danisola/restify/url/types/StrVar.java
// public static StrVar strVar(String id) {
//     return new StrVar(id);
// }


// Path: url/src/test/java/com/danisola/restify/url/UrlRestifyBenchmark.java
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
import static com.danisola.restify.url.RestParserFactory.parser;
import static com.danisola.restify.url.types.IntVar.intVar;
import static com.danisola.restify.url.types.StrVar.strVar;

package com.danisola.restify.url;



public class UrlRestifyBenchmark extends SimpleBenchmark {

    public RestParser timeCreatingParser(int reps) {
        RestParser parser = null;
        for (int i = 0; i < reps; i++) {
            parser = parser("/leagues/{}/teams/{}/players?age={}", strVar("leagueId"), strVar("teamId"),
                    intVar("playerAge"));
        }
        return parser;
    }

    public String timeParsing(int reps) {
        RestParser parser = parser("/leagues/{}/teams/{}/players?age={}", strVar("leagueId"), strVar("teamId"),