[ 
https://issues.apache.org/jira/browse/RANGER-3395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17412940#comment-17412940
 ] 

caozhiqiang commented on RANGER-3395:
-------------------------------------

!3395-1.png|width=916,height=211!

 

 

[~pradeep], above is a performance report from a java performance analyze tool. 
After removed Integer.toString() call, 
RangerDefaultAuditHandler.generateNextAuditEventId() would no longer appear in 
performance report.

And I also use below code to test Integer.toString() performance:

 
{code:java}
int nextId = counter.getAndIncrement();

long startTime = System.currentTimeMillis();
for (int i = 0; i < 500000; i++){
    ++nextId;
    String ret1 = UUID + Integer.toString(nextId);
}

long endTime   = System.currentTimeMillis();
long totalTime = endTime - startTime;
System.out.println(totalTime);


long startTime2 = System.currentTimeMillis();
for (int i = 0; i < 500000; i++) {
    ++nextId;
    String ret2 = UUID + nextId;
}
long endTime2   = System.currentTimeMillis();
long totalTime2 = endTime2 - startTime2;
System.out.println(totalTime2);
{code}
With Integer.toString() cost 64ms and without Integer.toString() only cost 
16ms, which case 1 takes 4 times as much time as case 2. Thanks for your review.

 

> Unnecessary 'Integer.toString()' call which degrade performance
> ---------------------------------------------------------------
>
>                 Key: RANGER-3395
>                 URL: https://issues.apache.org/jira/browse/RANGER-3395
>             Project: Ranger
>          Issue Type: Improvement
>          Components: plugins
>    Affects Versions: 2.0.1
>            Reporter: caozhiqiang
>            Assignee: caozhiqiang
>            Priority: Major
>         Attachments: 3395-1.png, RANGER-3395-branch-2.0.1.001.patch
>
>
> There are several place used unnecessary Integer.toString() call and take to 
> much time in program running. these should be removed.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to