package com.dianping.cat.consumer.advanced;

import junit.framework.Assert;

import org.junit.Test;


public class MetricAnalyzerTest {

	@Test
	public void test() {
		MetricAnalyzer analyzer = new MetricAnalyzer();
		String data = "aaa=1.1&a=1.1&abc=2.2&c=1.2&aaaa=11.1&abbbb=1.1&ssabc=2.2&sc=1.2";

		long t = System.currentTimeMillis();
		for (int i = 0; i < 10000000; i++) {
			analyzer.parseValue("abc", data);
		}
		
		System.out.println(System.currentTimeMillis() - t);

		Assert.assertEquals(analyzer.parseValue("aaa", "aaa=1.1"), 1.1);
		Assert.assertEquals(analyzer.parseValue("aaa", data), 1.1);
		Assert.assertEquals(analyzer.parseValue("a", data), 1.1);
		Assert.assertEquals(analyzer.parseValue("abc", data), 2.2);
		Assert.assertEquals(analyzer.parseValue("c", data), 1.2);
		Assert.assertEquals(analyzer.parseValue("aaaa", data), 11.1);
		Assert.assertEquals(analyzer.parseValue("abbbb", data), 1.1);
		Assert.assertEquals(analyzer.parseValue("ssabc", data), 2.2);
		Assert.assertEquals(analyzer.parseValue("sc", data), 1.2);
	}

}

@@ -359,20 +359,16 @@
 i %3C 1000
-0000
 ; i++) %7B
@@ -368,16 +368,16 @@
  i++) %7B%0A
+
 %09%09%09analy
@@ -528,19 +528,21 @@
 =1.1%22), 
+%22
 1.1
+%22
 );%0A%09%09Ass
@@ -584,35 +584,37 @@
 e(%22aaa%22, data), 
+%22
 1.1
+%22
 );%0A%09%09Assert.asse
@@ -646,35 +646,37 @@
 lue(%22a%22, data), 
+%22
 1.1
+%22
 );%0A%09%09Assert.asse
@@ -710,35 +710,37 @@
 e(%22abc%22, data), 
+%22
 2.2
+%22
 );%0A%09%09Assert.asse
@@ -776,27 +776,29 @@
 %22c%22, data), 
+%22
 1.2
+%22
 );%0A%09%09Assert.
@@ -845,20 +845,22 @@
  data), 
+%22
 11.1
+%22
 );%0A%09%09Ass
@@ -912,19 +912,21 @@
  data), 
+%22
 1.1
+%22
 );%0A%09%09Ass
@@ -978,19 +978,21 @@
  data), 
+%22
 2.2
+%22
 );%0A%09%09Ass
@@ -1041,19 +1041,21 @@
  data), 
+%22
 1.2
+%22
 );%0A%09%7D%0A%0A%7D

fix test case bug