RE: 答复: nGrinder port changes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RE: 答复: nGrinder port changes

junoyoon
Administrator

Well.. I understand what you concern. 


We should optimize the mostly executing code as much as possible. 


However, executing once a second is not a big deal. 


Java is much faster than you think.


If we can make clean code  which is executed not much. I'd rather to choose clean code.


Following is commented as I'm the author of it.. But It maybe come from prev-ngrinder 2.X version not from me..


public abstract class DateUtil { 


private static final SimpleDateFormat FULL_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());

/**

* Convert string date to Date with {@value #SIMPLE_DATE_FORMAT}.

* @param strDate

*            date string

* @return date

* @throws ParseException

*             occurs when given steDate is not {@link #SIMPLE_DATE_FORMAT}

*/

public static Date toSimpleDate(String strDate) throws ParseException {

return SIMPLE_DATE_FORMAT.parse(strDate);

}

}


We may have thought FULL_DATE_FORMAT  can be reused for every method invoke and enhance performance.

However, it's not.. It causes the defect.

Because SimpleDateFormat is not thread safe.. and causes a exception when this code is accessed by multiple thread.

Like this.. sometimes optimization can cause the defect.



What we should focus on in terms of performance is... SingleConsole#updateStatistics method I think..

It does a lot of job (including File IO) and frequently is invoked.


Regards.


이 메일은 나눔글꼴로 작성되었습니다. 설치하기

JunHo Yoon
Global Platform Development Lab
/ Senior Engineer

13th FL., Bundang First Tower, 266-1, Seohyeon-dong, Bundang-gu, Seongnam-si, Gyeonggi-do, 463-824, KOREA
Tel 031-600-9071   Fax --   Mobile 010-6255-0559
Email  [hidden email]

NHN Business & Platform NAVER HANGAME 쥬니어네이버 해피빈 미투데이


-----Original Message-----
From: "买乌拉江[Mavlarn]"<[hidden email]>
To: "윤준호[Juno/尹俊昊]"<[hidden email]>; "최중연[Isaiah]"<[hidden email]>; "买乌拉江[Mavlarn]"<[hidden email]>; "刘志飞[Tobi]"<[hidden email]>; "毛宇斌[Matt]"<[hidden email]>; "秦元[AlexQin]"<[hidden email]>;
Cc:
Sent: 2012-10-08 (월) 12:03:09
Subject: 答复: nGrinder port changes

Thanks Juno for your update, to help us to get updated.

 

And about the code, I have some idea. I hope we can discuss about it.

 

For example:

In PerfTestService class,

    public int getMaximumConcurrentTestCount() {

-       if (maximumConcurrentTestCount == 0) {

-           maximumConcurrentTestCount = config.getSystemProperties().getPropertyInt(

+       return config.getSystemProperties().getPropertyInt(

                           NGrinderConstants.NGRINDER_PROP_MAX_CONCURRENT_TEST,

                           NGrinderConstants.NGRINDER_PROP_MAX_CONCURRENT_TEST_VALUE);

-       }

-       return maximumConcurrentTestCount;

   }

 

Before, I added the maximumConcurrentTestCount, to avoid getting this property value every time from the properties map. It needs to look over the map, get the value in String, and convert it into int. And this function will be called every several seconds in background.

 

And another example, PerfTestRunnable,

    public void startTest() {

@@ -103,7 +107,7 @@ public class PerfTestRunnable implements NGrinderConstants {

-       // schedule test

-       Date schedule = (Date)ObjectUtils.defaultIfNull(runCandidate.getScheduledTime(), new Date());

-       long scheduleLong = schedule.getTime();

-       scheduleLong = scheduleLong / 1000 / 60;

-       scheduleLong = scheduleLong * 1000 * 60; //convert the time as the beginning of that minute.

-       if (System.currentTimeMillis() < scheduleLong) {

+       if (!isScheduledNow(runCandidate)) {

           // this test project is reserved,but it isn't yet going to run test

           // right now.

           return;

       }

 

    private boolean isScheduledNow(PerfTest test) {

        Date current = new Date();

        Date scheduledDate = DateUtils

                       .truncate((Date) defaultIfNull(test.getScheduledTime(), current), Calendar.MINUTE);

        return current.after(scheduledDate);

    }

 

This code will be called every 5 seconds too. In the isScheduledNow function, we created a new Date, in DateUtils.truncate() function also created a Calendar object, and the truncate()  and  after() function are more complicated than before.

 

What I think is, although these utility function is really easy to use and make the code clear. But at the same time, they also used many resources for the standard utility. Maybe it will not affect the system performance a lot, but it definitely will. If there are many these kind of code, maybe it will affect a lot.

 

So, I think we should consider a little more before we use them.

 

How do you guys  thing?

 

 

 

发件人: Yoon, JunHo [mailto:[hidden email]]
发送时间: 2012928 15:26
收件人: BJ_NGRINDER_DEV
抄送: 杜斑[Du Ban]
主题: nGrinder port changes

 

Dear nGrinder developer...

 

In NHN korea, there are some task for the network isolation.

They will block all ports under 10000 and only allows some 80, 8080 port to communicate b/w dev network and real service network.

Currently we use following port.

 

- Agent Controller Server : 7001

- Console Port : 12000

- Monitoring Port : 3243

 

AgentControllerServer and Monitoring port will be blocked by that limitation.

 

So I changed port like following.

- Agent Controller Server : 16001

- Console Port : 12000

- Monitoring Port : 13243

 

To get effective, we should update monitor and controller and agents..

Please be aware it.

 

Regards.

 

메일은 나눔글꼴로 작성되었습니다. 설치하기

JunHo Yoon
Global Platform Development Lab
/ Senior Engineer

13th FL., Bundang First Tower, 266-1, Seohyeon-dong, Bundang-gu, Seongnam-si, Gyeonggi-do, 463-824, KOREA
Tel 031-600-9071   Fax --   Mobile 010-6255-0559
Email  [hidden email]

NHN Business & PlatformNAVERHANGAME쥬니어네이버해피빈미투데이

 

Reply | Threaded
Open this post in threaded view
|

RE: 答复: nGrinder port changes

Mavlarn
well, I still think we should consider performance anytime. Although Java will help us do some optimization, and JVM is really fast. We should also try to write clean and fast code.

About the formatter, I didn't notice it before, I just realized this problem.
I think, we can remove all formatting in server side for double numbers. Because we have already done most of the formatting in freemarker.
Reply | Threaded
Open this post in threaded view
|

RE: 答复: nGrinder port changes

junoyoon
Administrator

:-) Just start from the important part. 

As I told you, 


I think updataStatistics are the most resource taking placel.



JunHo Yoon
Global Platform Development Lab
/ Senior Engineer

13th FL., Bundang First Tower, 266-1, Seohyeon-dong, Bundang-gu, Seongnam-si, Gyeonggi-do, 463-824, KOREA
Tel 031-600-9071   Fax --   Mobile 010-6255-0559
Email  [hidden email]

NHN Business & Platform NAVER HANGAME 쥬니어네이버 해피빈 미투데이


-----Original Message-----
From: "Mavlarn [via ngrinder]"<[hidden email]>
To: "junoyoon"<[hidden email]>;
Cc:
Sent: 2012-10-08 (월) 18:07:39
Subject: RE: 答复: nGrinder port changes

well, I still think we should consider performance anytime. Although Java will help us do some optimization, and JVM is really fast. We should also try to write clean and fast code.

About the formatter, I didn't notice it before, I just realized this problem.
I think, we can remove all formatting in server side for double numbers. Because we have already done most of the formatting in freemarker.


If you reply to this email, your message will be added to the discussion below:
http://ngrinder.642.n7.nabble.com/RE-nGrinder-port-changes-tp3p11.html
To start a new topic under ngrinder_dev, email [hidden email]
To unsubscribe from ngrinder_dev, click here.
NAML