Saturday, June 5, 2010

How to use and install Yourkit, Java Profiler with YourKit



Java Profiling:

In software engineering, program profiling, software profiling or simply profiling, a form of dynamic program analysis, is the investigation of a program's behavior using information gathered as the program executes. The usual purpose of this analysis is to determine which sections of a program to optimize - to increase its overall speed, decrease its memory requirement or sometimes both.


There are many profiler are available in the market for Java. But I use yourkit java profile and going to step by step setup.


How you can profile your java application using yourkit Java profiler.


1. Download yourkit java profiler from here. You can download trial version for 2 weeks and see the website for more information.
2. During installation it will ask path to insatll the yourkit. Give any path but without space like c:\yourkit
3. Create one small project in Eclipse say(JavaTest)
4. Create one simple Java file to check in profiler say (App.java)


App.java
package com.binod.suman;


/**
* Author @ Binod Suman
*/


public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
App test = new App();
test.check();
}


public void check(){
String name="Binod";
System.out.println(getName(name));
}


public String getName(String s){
System.out.println("YES :: "+s);
for(int i=0;i<10000;i++){
try { Thread.sleep(1000); }
catch (InterruptedException e) { e.printStackTrace(); }
System.out.println(s);
} return s;
}
}

5. First start the yourkit. (Start -> All Programs -> Yourkit java profiler -> Yourkit java profiler .
The profiler can automatically detect all locally running profiled applications. If more than one is found, you will be asked to select one. If only one application is found, the profiler will connect to it without prompting you.


6. Now run your App.java now see the YourKit Profiler

It will show one Application runnig (com.binod.suman.App) started without profiler. If you will double click on the application,


YourKit will show one error message that The application cannot be profiled because it has not been started with the profiler.


So, now how you will connect your application with YourKit profiler

1. In Eclispe, right click on the mail java file (App.java) -> Run As -> Run Configurations ... -> Go to Second Tab Argumetns -> Go to VM arguments: and paste
-agentpath:C:\yourkit\bin\win32\yjpagent.dll
click on Apply then Run.

Next time onward no need to do all these thing, just run it.


Now come to Yourkit profiler this time it will show Started with profiler
Now you can double click on your application (App) and it will show all the CPU, Thread, Memory, Deadloccks, Garbage Collection, Summary details of the your application.

Source

Thanks .......... :)

Monday, March 29, 2010

VXML Getting Started, VXML fundamental, VXML easy example

VXML (=Voice XML)
Ref: http://www.ibm.com/developerworks/library/wa-voicexml/


Java is very famous for develop web application. In web application we will have UI and we can enter any dataor fetch data using that UI. Nowadays Phone or mobiel are very common, so we should have some technology to access our java code using the mobile and that is called VXML technology.


A simple VXML page (Say First.vxml)
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">
<form>
<block>
<prompt> Hi Binod your first VXML Applciationi is working fine, Congratulations. </prompt>
</block>
</form>
</vxml>

Save this file say (D:\Binod)

You can check your vxml syntax here at cafe.bevocal.com. First need registration then you can check your code here itself. Really very nice.

To access this file, we have to upload this file for publically accessible. Some vxml interpreter should be thereto understand all vxml tags. The famous server is telco server. But to run vxml example from home or for learing purposem, we can use https://evolution.voxeo.com/ site.
Unlike traditional Web applications, you can't just open up a Web browser and surf on over to your VXML file; at least, not if you want a voice response. To test out a phone-based application, you obviously need a phone, and that implies a number to call. There are plenty of high-dollar approaches to mapping numbers to VoiceXML applications, but for testing, staging, and development, Voxeo offers a great free mapping service.
Navigate over to http://evolution.voxeo.com/,create username and password and log in (using the fields on the upper left side of the page). Under Account menu, select File, Logs, & Report option -> doulbe click on www -> go to first upload file secion and click on Browse and choose d:\Binod\First.vxml click open. Now click on Upload button.
Again click on Account menu then click on Application Manager ->

Add Application Give any name to your application say Binod_First_IVRThen click on Voice Phone Calls option, DONT change any option in voice application type. in Voice URLclick on file manager hyperlink you will be getting here your uploade file First.vxml, select this fileand click on map button. DONOT change any thing in Phone number combo box. Simple click on Create Application button.

You will be getting one mail to your mail box. :)

click on Contact Methods tab.copy Skype voip number and dial same number from your skype account.(If you dont have skype account then please go to http://www.skype.com/ and download skype and create one account then only you will be able to call this number).

If you want to edit your vxml file then Account -> Aplication Manager -> click on Binod_First_IVR, click on edit file (option is near to * Voice URL)Once file will get open you can change and just click on save change. Now you can check your new update after calling from skype.

For debugging: Account -> Application Debugger now call from skype then data will be show here in debugger.

Some other example on Input.
Second.vxml

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">

<field name="xx" type="digits">
<prompt>
welcome to ivrs process BY Binod.
Please select the desired language.
press 1 for english.
press 2 for HINDI.
</prompt>

<filled>

<if cond="xx==1"> <prompt> YOU HAVE ENTERD ENGLISH </prompt> <elseif cond="xx==2"/> <prompt> YOU HAVE ENTERD HINDI </prompt> <else/> <prompt> Please choose correct option </prompt>
</if>
</filled>
</field>
</form>
</vxml>

Some more advacne input program.

If user does not give correct input then it should repromt for 3 times.

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<field name="xx" type="digits">
<prompt>
welcome to TecnoTree IVR.
Please select the desired language.
press 1 for english.
press 2 for HINDI.
</prompt>
<filled>

<if cond="xx==1">
<prompt> YOU HAVE ENTERD ENGLISH </prompt>
<elseif cond="xx==2"/> <prompt> YOU HAVE ENTERD HINDI </prompt> </if> </filled> </field>
<noinput>
<prompt> We didnt get any input from you </prompt>
<reprompt/>

</noinput>
<nomatch>
<prompt> not a valid input</prompt> <reprompt/> </nomatch>

<nomatch count="3">
<prompt> You have reached maximum tried</prompt> <exit/> </nomatch>
</form>
</vxml>
This will only work for * or # incase of no match.

Another Example:
Take one input and prompt same number:

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<field name="xx" type="digits">

<prompt> Enter any digit </prompt>
<filled>
<prompt> you have entered <value expr="xx"/> </prompt> </filled>
</field>
</form>
</vxml>

calculator.vxml

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<var name="x" expr="0"/>
<var name="y" expr="0"/>
<!-- <var name="zz" expr="0"/> -->
<field name="xx" type="number">
<prompt>Welcome to IVR Calculator. Enter any digit </prompt>

<filled>
<assign name="x" expr="xx"/>
<prompt> you have entered <value expr="xx"/> </prompt>
<goto nextitem="yy"/>
</filled>
</field>

<field name="yy" type="number">
<prompt> <break time="2s"/> Enter Second any digit </prompt> <filled> <assign name="y" expr="yy"/>
<script>
var zz= Number(x)+Number(y);
</script>
<prompt> you have entered Second digit <value expr="yy"/>
<!-- Now the total value <value expr="xx+yy"/> -->
</prompt>
<!-- <assign name="zz" expr="Number(x)+Number(y)"/> --> <prompt> <break time="2s"/> The Answer after addition two number is <value expr="zz"/> </prompt>
</filled>
</field>

<field name="again" type="number">
<prompt> <break time="1s"/>
Press 1 for add another number.
Press 2 for exit.
</prompt>
<filled>
<if cond="again==1"> <prompt> YOU HAVE SELECTED ONE </prompt> <goto nextitem="xx"/>
<elseif cond="again==2"/> <prompt> YOU HAVE SELECTED TWO </prompt> <exit/>
</if>
</filled>
</field>
</form>
</vxml>

Recording Example
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<form id="F1">
<record name="R_1" beep="true" dtmfterm="true">
<prompt> Good Morning. Welcome to Binod Suman IVR. You can record your message after hear beep.
</prompt>

<prompt> after you are finished, Please press hash button </prompt>

<filled> <log expr="R_1$.duration"/> <log expr="R_1$.termchar"/> <log expr="R_1$.size"/>
<prompt> your recording was <value expr="R_1"/> THANK YOU FOR USING BINOD IVR APPLICATION. </prompt> </filled>
</record>
</form>
</vxml>