import java.util.*;
import java.lang.*;
class Main
{
private static void test
(String regex,
String replace,
int repetitions
) {
long startTime
= System.
currentTimeMillis(); for (int i = 0; i < repetitions; i++)
{
String str
= "30-Nov-2012 United Kingdom, 31-Oct-2012 31-Oct-2012 United Arab Emirates, 29-Oct-2012 31-Oct-2012 India, "; str.replaceAll(regex, replace);
}
long endTime
= System.
currentTimeMillis(); System.
out.
println("Execution time: " + Long.
toString(endTime
- startTime
)); }
{
test("(\\d{4})\\s", "$1@", 10000);
test("(?<=\\d{4})\\s", "@", 10000);
test("(\\d{4})\\s", "$1@", 10000);
test("(?<=\\d{4})\\s", "@", 10000);
test("(\\d{4})\\s", "$1@", 10000);
test("(?<=\\d{4})\\s", "@", 10000);
test("(\\d{4})\\s", "$1@", 10000);
test("(?<=\\d{4})\\s", "@", 10000);
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CiAKY2xhc3MgTWFpbgp7CiAgICBwcml2YXRlIHN0YXRpYyB2b2lkIHRlc3QgKFN0cmluZyByZWdleCwgU3RyaW5nIHJlcGxhY2UsIGludCByZXBldGl0aW9ucykKICAgIHsKICAgICAgICBsb25nIHN0YXJ0VGltZSA9IFN5c3RlbS5jdXJyZW50VGltZU1pbGxpcygpOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcmVwZXRpdGlvbnM7IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIFN0cmluZyBzdHIgPSAiMzAtTm92LTIwMTIgVW5pdGVkIEtpbmdkb20sIDMxLU9jdC0yMDEyIDMxLU9jdC0yMDEyIFVuaXRlZCBBcmFiIEVtaXJhdGVzLCAyOS1PY3QtMjAxMiAzMS1PY3QtMjAxMiBJbmRpYSwgIjsKICAgICAgICAgICAgc3RyLnJlcGxhY2VBbGwocmVnZXgsIHJlcGxhY2UpOwogICAgICAgIH0KICAgICAgICBsb25nIGVuZFRpbWUgPSBTeXN0ZW0uY3VycmVudFRpbWVNaWxsaXMoKTsKICA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