From b5f404c6d00d5cdf02a8b9fb62ddb5057a1e8deb Mon Sep 17 00:00:00 2001 From: Bon-Yong Lee Date: Thu, 10 Oct 2013 15:23:36 +0900 Subject: [PATCH] [Title] Modify script for performance test [Desc.] [Issue] Signed-off-by: Bon-Yong Lee --- .../tizen-ide-ui-test.sikuli/tizen-ide-ui-test.py | 1 + .../test/src/org/tizen/common/LogConverter.java | 137 +++++++++++++++++++++ .../src/org/tizen/common/LogConverterTest.java | 28 +++++ 3 files changed, 166 insertions(+) mode change 100644 => 100755 org.tizen.common/test/sikuli/tizen-ide-ui-test.sikuli/tizen-ide-ui-test.py create mode 100755 org.tizen.common/test/src/org/tizen/common/LogConverter.java create mode 100755 org.tizen.common/test/src/org/tizen/common/LogConverterTest.java diff --git a/org.tizen.common/test/sikuli/tizen-ide-ui-test.sikuli/tizen-ide-ui-test.py b/org.tizen.common/test/sikuli/tizen-ide-ui-test.sikuli/tizen-ide-ui-test.py old mode 100644 new mode 100755 index f865b08..86c4c69 --- a/org.tizen.common/test/sikuli/tizen-ide-ui-test.sikuli/tizen-ide-ui-test.py +++ b/org.tizen.common/test/sikuli/tizen-ide-ui-test.sikuli/tizen-ide-ui-test.py @@ -109,3 +109,4 @@ click(Pattern("1373883294273.png").targetOffset(-17,1)) sleep( 1 ) doubleClick(Pattern("1373885544264.png").targetOffset(-29,1)) sleep( 1 ) +print "%s" % ("[info]" Exit code: 0") \ No newline at end of file diff --git a/org.tizen.common/test/src/org/tizen/common/LogConverter.java b/org.tizen.common/test/src/org/tizen/common/LogConverter.java new file mode 100755 index 0000000..b81bd1a --- /dev/null +++ b/org.tizen.common/test/src/org/tizen/common/LogConverter.java @@ -0,0 +1,137 @@ +package org.tizen.common; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.text.MessageFormat; +import java.text.ParseException; +import java.util.ArrayList; + +public class LogConverter +{ + protected static final String PATTERN = "[{0}][PERFORM_E] {1}({2}) - [Category: {3} Variable: {4}] at {5} {6} [{7}(ms)]"; + + protected static final MessageFormat FORMAT = new MessageFormat( PATTERN ); + + protected class TestCase { + protected String className; + protected String name; + protected String time; + + public TestCase(String className, String name, String time) + { + super(); + this.className = className; + this.name = name; + this.time = time; + } + + + + @Override + public String toString() + { + return ""; + } + } + + public static + void + main( + final String[] args + ) throws IOException + { + if ( args.length < 2 ) + { + return ; + } + + final File from = new File( args[0] ); + if ( !from.exists() || from.isDirectory() || !from.canRead() ) + { + return ; + } + + final File to = new File( args[1] ); + if ( from.isDirectory() || !from.canWrite() ) + { + return ; + } + + final LogConverter instance = new LogConverter(); + instance.convert( new FileReader( from ), new FileWriter( to ) ); + + } + + protected + String[] + parse( + final String line + ) + { + try + { + final Object[] args = FORMAT.parse( line ); + if ( args.length < 8 ) + { + return null; + } + final String category = (String) args[3]; + final String variable = (String) args[4]; + final String time = (String) args[7]; + return new String[] { category, variable, time }; + } + catch ( ParseException e ) + { + return null; + } + + } + + protected + void + convert( + final Reader reader, + final Writer writer + ) + throws IOException + { + final BufferedReader lineReader = new BufferedReader( reader ); + String line = null; + final ArrayList testCases = new ArrayList(); + long time = 0; + while ( null != ( line = lineReader.readLine() ) ) + { + final String[] args = parse( line ); + if ( null == args ) + { + continue; + } + testCases.add( new TestCase( args[0], args[1], args[2] ) ); + try + { + time += Integer.parseInt( args[2] ); + } + catch( final NumberFormatException e ) + { + } + } + + writer.append( "\n" ); + try + { + for ( final TestCase testCase : testCases ) + { + writer.append( "\t" + testCase.toString() + "\n" ); + } + } + finally + { + writer.append( "" ); + } + } +} diff --git a/org.tizen.common/test/src/org/tizen/common/LogConverterTest.java b/org.tizen.common/test/src/org/tizen/common/LogConverterTest.java new file mode 100755 index 0000000..35b5811 --- /dev/null +++ b/org.tizen.common/test/src/org/tizen/common/LogConverterTest.java @@ -0,0 +1,28 @@ +package org.tizen.common; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class LogConverterTest +{ + + @Test + public void test_parse() + { + final Object[][] TEST_CASES = new Object[][] { + new Object[] { "[2013.10.10 15:00:18][PERFORM_E] TizenLaunchDelegate.java(804) - [Category: native.launch Variable: .install] at 2013-10-10 15:00:18.223 [2917(ms)]", new String[] { "native.launch", ".install", "2917" } } + }; + + final LogConverter target = new LogConverter(); + for ( final Object[] TEST_CASE : TEST_CASES ) + { + final String input = (String) TEST_CASE[0]; + final String[] expect = (String[]) TEST_CASE[1]; + final String[] result = target.parse( input ); + + assertArrayEquals( expect, result ); + } + } + +} -- 2.7.4