Is this logging code faster than using a standard logging API like log4J

is this logging code faster than using a standard logging API like log4J or the logging API in java 1.4
As you can see my needs are extremely simple. write some stuff to text file and write some stuff to dos window.
I am thinking about using this with a multi threaded app. So all the threads ~ 200 will be using this simultaneously.
* Tracer.class logs items according to the following criteria:
* 2 = goes to text file Crawler_log.txt
* 1 = goes to console window because it is higher priority.
* @author Stephen
* @version 1.0
* @since June 2002
import java.io.*;
import java.net.*;
import java.util.*;
import java.text.*;
class Tracer{
public static void log(int traceLevel, String message, Object value)
if(traceLevel == 1){
System.out.println(getLogFileDate(new Date()) +" >" + message+ " value = " + value.toString()););
}else{
pout.write(getLogFileDate(new Date()) +" >" + message + " value = " + value.toString());
pout.flush();
public static void log(int traceLevel, String message )
if(traceLevel == 1){System.out.println(message);
}else{
pout.write(message ) ;
pout.flush();
//public static accessor method
public static Tracer getTracerInstance()
return tracerInstance;
private static String getLogFileDate(Date d )
String s = df.format(d);
String s1= s.replace(',','-');
String s2= s1.replace(' ','-');
String s3= s2.replace(':','.');
System.out.println("getLogFileDate() = " + s3 ) ;
return s3;
//private instance
private Tracer(){
System.out.println("Tracer constructor works");
df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
date = new java.util.Date();
try{
pout = new PrintWriter(new BufferedWriter(new FileWriter("Crawler_log"+getLogFileDate(new Date())+".txt", true)));
pout.write("**************** New Log File Created "+ getLogFileDate(new Date()) +"****************");
pout.flush();
}catch (IOException e){
System.out.println("**********THERE WAS A CRITICAL ERROR GETTING TRACER SINGLETON INITIALIZED. APPLICATION WILL STOP EXECUTION. ******* ");
public static void main(String[] argz){
System.out.println("main method starts ");
Tracer tt = Tracer.getTracerInstance();
System.out.println("main method successfully gets Tracer instance tt. "+ tt.toString());
//the next method is where it fails - on pout.write() of log method. Why ?
tt.log(1, "HIGH PRIORITY");
System.out.println("main method ends ");
//private static reference
private static Tracer tracerInstance = new Tracer();
private static Date date = null;
private static PrintWriter pout = null;
public static DateFormat df = null;
}

In general I'd guess that a small, custom thing will be faster than a large, generic thing with a lot of options. That is, unless the writer of the small program have done something stupid, og the writer of the large program have done something very smart.
One problem with java in this respect is that it is next to impossible to judge exactly how much machine-level processing a single java statement takes. Things like JIT compilers makes it even harder.
In the end, there is really only one way to find out: Test it.

Similar Messages

  • Can this class run fast than Hotspot ?

    My case in Sun hotspot is almost 2 times fast than jRockit. It's very strange.
    package com.telegram;
    public class byteutils {
         public final static byte[] bytea = { 48, 49, 50, 51, 52, 53, 54, 56, 57,
                   58, 65, 66, 67, 68, 69, 70 };
         public byteutils() {
              super();
         * convert length = 2L letters Hexadecimal String to length = L bytes
         * Examples: [01][23][45][67][89][AB][CD][EF]
         public static byte[] convertBytes(String hexStr) {
              byte[] a = null;
              try {
                   a = hexStr.getBytes("ASCII");
              } catch (java.io.UnsupportedEncodingException e) {
                   e.printStackTrace();
              final int len = a.length / 2;
              byte[] b = new byte[len];
              int idx = 0;
              int h = 0;
              int l = 0;
              for (int i = 0; i < len; i++) {
                   h = a[idx++];
                   l = a[idx++];
                   h = (h < 65) ? (h - 48) : (h - 55);
                   l = (l < 65) ? (l - 48) : (l - 55);
                   // if ((h < 0) || (l < 0)) return null;
                   b[i] = (byte) ((h << 4) | l);
              a = null;
              return b;
         public static String convertHex(byte[] arr_b) {
              if (arr_b == null)
                   return null;
              final int len = arr_b.length;
              byte[] byteArray = new byte[len * 2];
              int idx = 0;
              int h = 0;
              int l = 0;
              int v = 0;
              for (int i = 0; i < len; i++) {
                   v = arr_b[i] & 0xff;
                   l = v & 0xf;
                   h = v >> 4;
                   byteArray[idx++] = bytea[h];
                   byteArray[idx++] = bytea[l];
              String r = null;
              try {
                   r = new String(byteArray, "ASCII");
              } catch (java.io.UnsupportedEncodingException e) {
                   e.printStackTrace();
              } finally {
                   byteArray = null;
              return r;
         public static void main(String[] argv) {
              byte[] a = new byte[0x10000];
              for (int c = 0; c < 0x10000; c++) {
                   a[c] = (byte) (c % 256);
              String s = "";
              int LOOP = 10000;
              long l = System.currentTimeMillis();
              for (int i = 0; i < LOOP; i++) {
                   s = convertHex(a);
                   a = convertBytes(s);
              l = System.currentTimeMillis() - l;
              double d = l / (double) LOOP;
              System.out.println("" + d + "ms.");
    }

    Thanks! Your code is essentially a microbenchmark testing the performance of sun.nio.cs.US_ASCII.Decoder.decodeLoop() and encodeLoop(), with ~35% and ~30% spent in those two methods respectively. I have verified the behavior (i.e. Sun is faster than JRockit). Due to the microbenchmark nature, it may not affect a larger running program, but it may merit a closer look regardless. I have forwarded to the JRockit perf team for analysis.
    -- Henrik

  • Is JDK1.4.0 compiled code faster than JDK1.3.1?

    I'm compiling my code using JDK1.3.1, but I'm running it using JRE1.4.0. If I compile all of my code using JDK1.4.0, should I expect a performance boost? Particularly in terms of GUI components?
    The reason I haven't compiled in JDK1.4.0 is because I'm using Forte, and it has some major Form Editor bugs when running with JDK1.4.0, so I can't use it at this time.
    Thanks.

    Hi, referring to the latest Java Live Session (High Performance GUIs With the JFC/Swing API, http://developer.java.sun.com/developer/community/chat/JavaLive/2002/jl0423.html), you will get better performance, although "boost" would be quite optimistic.
    Here's a snipped from that session:
    "... SeanOfVA: Are the performance improvements in v1.4 such that a Swing application compiled with v1.3.x, but executed in a v1.4 JVM would exhibit improved performance? There are a variety of reasons I would prefer not to incorporate 1.4 features yet into my source code base.
    WilsonSD: Absolutely. For starters look at the Performance and Scalability Guide [http://java.sun.com/j2se/1.4/performance.guide.html]. Specifically, the enhancements in Java2D will provide nice speed-ups for typical Swing apps in terms of GUI responsiveness. The 2D pipeline architecture allows for faster performance on many graphics operations. Since Swing uses J2D your Swing application benefits. Also, the Swing "back buffer" was rewritten to use the new 2D VolitileImage class. This will give many parts of your Swing application access to hardware acceleration without recoding..."
    Patrick

  • Would sorting in UNIX faster than using order by?

    Hi all, recently I was trying to optimize a query that returns a million rows. After using explain plan, I found that the 'order by' (3 columns needed) clause contributes to a significant portion of the cost.
    I wonder if the process can be speed up by doing the query straight without ordering, then use the UNIX sort command (with the help of other commands, such as sed, awk... etc.) to perform the 'order by' instead. Of course you'll need to supply a whole bunch of strange parameters to sort command to make it work as expected.
    But in terms of performance when the result set is huge, which one is faster? 'Order by' or UNIX sort?
    Many thanks.

    What are you sorting by ?
    If it is a date and the output formats it with a 'Mon' component, then I'd bet on Oracle rather than any user written logic converting JAN to 01 etc.
    As for the rest of it, it may depend on the memory allocated to the processes (so PGA setting may improve query performance). A million rows would probably require a disk sort, so the location/speed of that file would impact it too.

  • How can i sort out the N lowiest elements from an 1D array faster than using the build in sort function (1D-array) in Labview?

    I need an algorithm that is based on the same sorting-algorithm that Labview uses (or one that is just as fast) but it only needs to sort out the N lowiest elements (and the N-element output array don't need to be sorted).
    /Jonas

    I want all three zeros in the output. You can se the algorithm that I'm looking for as a soft version of Labviews own sort algorithm that only gives you the N (always less then the length of the array) lowiest values as output.If two elements contain the same small value both should be sorted out.
    /Jonas

  • How to write this java code in jsp using jstl  tags?

    Can anybody help me on this?
    I dont know how to check the containsKey using jstl tags?
    <%
         LinkedHashMap yearMap     =     (LinkedHashMap)request.getAttribute("yearMap");
         TreeSet nocSet               =     (TreeSet)request.getAttribute("nocSet");
         Iterator     yearMapIt     =     yearMap.keySet().iterator();
         while(yearMapIt.hasNext())
              int yearValue               =     (Integer)yearMapIt.next();
    %>
    <tr>
              <td><%=yearValue%></td>
    <%
              LinkedHashMap monthMap     =     (LinkedHashMap)yearMap.get(yearValue);
              Iterator     nocSetIt     =     nocSet.iterator();
              while(nocSetIt.hasNext())
                   String nCase=(String)nocSetIt.next();
                   if(monthMap.containsKey(nCase))
                        String count     =     (String)monthMap.get(nCase);
    %>
                        <td> <%= count %> </td>
    <%            }
                   else
    %>          
                        <td> 0 </td>     
    <%          
    %>
    </tr>
    <% } %>Edited by: avn_venki on Feb 18, 2008 11:54 PM

    <c:forEach var="yearMap" items="${requestScope.yearMap}">
         <th> <c:out value="${yearMap.key}"/> </th>
    <bean:define id="monthMap" value="${yearMap.value}"/>
    <c:forEach var="nocSet" items="${nocSet}">
    then how to write containsKey using tags??

  • New Mac Pro 8-core / D700 not much faster than an iMac... in PPro CC.

    So.... my very preliminary testing with our new Mac Pro using the plugin I use most (filmconvert -FC) anyway, shows that Premiere CC needs more optimization for the dual GPUs. In fact, I'd say the CPU utilization is not up to snuff either.
    I know FC only uses one GPU presently from the developer. That will change. In the meantime, using a couple of typical projects with that plugin as an example, I'm only seeing 25-45% speed up in renders over our maxed out iMac (late 2012, 27") exporting the same project. That's significant of course but not the 100%+ one would think we would be seeing at the least given the MacPro config of 8 cores and dual D700s. Premiere Pro CC seems in fact to never maximize CPU (never mind GPUs). I have yet, in my very limited testing, see it "pin the meters" like I did on the iMac.
    Of course that's just testing now two short (under 5 min) projects, and it depends on what one is doing. Some stuff is much, much faster like Red Giant's Denoiser II or Warp Stabilizer VFX. The improvement there can be 3-4x faster anecdotally.  I used to avoid them for speed reasons unless absolutely needed a lot of the time but now they are fast enough to rely on quickly. Other stuff unrelated top PPro CC like DxO PRIME noise removal on RAW stills is much faster too, as is Photoshop CC.  Some effects like blur, sharpening, resize there are nearly instant now even on giga pixel files in Photoshop CC.
    And of course FCPX is much faster on it but I hate the whole editing paradigm. The timeline is just horrid on it; simple things like replacing a word in someone's dialogue is a multi click, multistep process that is nearly instant in Premiere and most every other NLE. Just to try to see your whole timeline is a chore, to see what your edits and sound are in detail are problematic, trying to keep things in sync is a chore, and you can't even zoom your timeline window to full screen! If anybody has edited for any amount of time, I do not understand how they use FCP X. If they start with that program, for example if they are young, then that is a different beast.
    I'm sure Adobe will improve over time. They have to to stay competitive. In the meantime I'll take my 45%... but I wish I saw much more improvement given the cost and hardware differential. Unfortiunately, for now, the mainstream reviews I have seen regarding PPro performance on this machine were right.

    That statement about 4k/5k in Premiere CC with the nMP is false, insofar as performance goes.
    I just tested 5K Red raw files just dragged into Premiere Pro CC (latest version). I expected this to be slow, given my HD experience. However, on my 8 core/D700, I can play 1/2 just fine, full speed. And I even can also do that with a very streneous plugin/filter attached - FilmConvert (in OpenCL mode), also at 1/2 which is quite impressive. I can even add a bunch of other Premiere filters and SG looks and it still stays at full speed at 1/2.
    Ironically, this is quite faster than FCPX which can't seem to play back 5K at all with that filter attached (it doesn't stutter, but it's not smooth... low resolution at "best performace" and reduced frame rate). Even if I remove all filters FCPX plays back Red 4k (again not transcoded) about the same as CC at 1/2, but with a seemingly lower resolution to keep it smooth.  It's a head scratcher. It's like Adobe's Red handling is much better coded than Apple's in this case.
    Or... it has to be attrituable to that particular plugin (other FCPX motion-based plugins don't suffer the same fate and are fast). But either way, filter or no, Premiere Pro CC is definitely and sharper looking at 1/2 when cutting Red 4k/5k with no transcode, playback in real time, than FCPX which needs to bump it down to what looks like a 1/4 or less rez to keep it smooth. So I have no idea what is going on.
    This experience is the opposite with HD, where FCPX is significantly faster (using the same filters/plugin, using C300 Canon XF for HD and 4 and 5K RedRaw alternatively).  Premiere seems slower in HD than FCPX by a good amount in HD and signficantly faster with Redraw 4k. Go figure.

  • Download Data From Excel - VBA Code to SAP Using BDC

    Hi ,
    I am Sudhir Dure, working with Satyam Computers.
    I need help on the below query:
    I have an excel file which download data from Excel to SAP using RFC function & with the help of VBA interface.
    In this VBA code I have used BDC recording of SAP Transaction KE21N to post data into SAP.
    Now I am facing problem to find sub screen (tab page screen ) in SAP from VBA code .
    How to pass BDC Subscreen details from VBA code to SAP using below code?
    BDCTABLE.Rows.Add
    BDCTABLE.Cell(J, "PROGRAM") = PROGRAMNAME
    BDCTABLE.Cell(J, "DYNPRO") = "0200"
    BDCTABLE.Cell(J, "DYNBEGIN") = "X"
    BDCTABLE.Cell(J, "FNAM") = "BDC_OKCODE"
    BDCTABLE.Cell(J, "FVAL") = "=NEXT"
    Thanks,
    Sudhir Dure
    9972097464

    can anyone tell me how to get the PurchaseOrder number and item quantity from the Salesorder...? what are the fields here as given below..??
    For Each oItem In oSalesOrder.items
    wsTemplate.Range(cols(3) & Indexv).Value = oItem.material.material
    'wsTemplate.Range(cols(4) & Indexv).Value = ' I need item quantity here ????
    wsTemplate.Range(cols(1) & Indexv).Value = sapSoNumber
    wsTemplate.Range(cols(2) & Indexv).Value = ' I need purchase order number here>???
    Indexv = (Indexv + 1)
    Next
    reply fast. please .. thanks

  • How to use the change log in ODS to track Delta change?

    People say that historical data (like Delta change) in ODS can be tracked in the Change Log.  How to use the change log to track historic data?
    Thanks

    Kevin
    See if it helps
    Every ODS object is represented on the database by three transparent tables:
    Active data: A table containing the active data (A table)
    Activation queue: For saving ODS data records that are to be updated but that have not yet been activated. The data is deleted after the records have been activated.
    <b>Change log: Contains the change history for delta updating from the ODS Object into other data targets, such as ODS Objects or InfoCubes for example.</b>
    An exception is the transactional ODS object, which is only made up of the active data table.
    The tables containing active data are constructed according to the ODS object definition, meaning that key fields and data fields are specified when the ODS object is defined. Activation queue and change log are the same in the table’s structure. They have the request ID, package ID and the record number as a key.
    Data base structure changes
    http://help.sap.com/saphelp_nw04/helpdata/en/d2/d53ec3efdc9b47a9502c3a4565320c/frameset.htm
    Hope this helps
    Thnaks
    Sat

  • Automatic FASTER-THAN-RT screen shots?

    hi everyone. we have recently received a drive of about 80
    movies with at least 5 (sometimes 9) scenes each.. we need to take
    12 screenshots from each scene.. is there a tool that can do this
    randomly at FASTER than real-time??
    thanks.
    Logan

    Thank you so much wchp, this is brilliant. I have had this annoying problem for a long time. I eventually rang Mac support, they did not know how to fix the problem as you have suggested so they instigated many hardware replacements which eventually left my iMac severely crippled. They eventually replaced it with the latest model. But I spent two months working with a disabled computer which really interfere with my work.
    Your solution appears to have solved my problem, at least so far, but I am hopeful that it is a permanent fix. I hope that your suggestions are taken up by Apple support. This may solve many users problems and avoid Apple making expensive fixes that don't actually work.
    I thought that the new iMac would not have the 'Wake up from sleep by painting in the login window' problem but it did, this really annoyed me. Anyway now the problem appears to be solved, it's not I will repost and keep working on it. Thanks again.

  • What's This Help crashing when using RoboHelp's HtmlHelp API

    I followed all the instructions described in the RoboHelp
    developer help file. The correct initialisation at the InitInstance
    of the application
    is called using the CSHInitialize(szHelpPath, TRUE). Then, I
    registered the dialog for the "What's This?" help, using the
    SHRegisterDialog(...) API. When I right click the mouse on any
    control in the dialog I always end up with a crash reporting the
    following error:
    "The exception unknown software exception (0x0000005) occurred
    in the application at location 0x4b78d471".
    When we debugged the problem we got the following message in
    the debugger which indicates that the crash is happining in the
    hhctrl.ocx library:
    "Unhandled exception at 0x4b78d471 (hhctrl.ocx) in hoblinkl.exe;
    0x0000005: Access violation reading location 0x00000000"
    In the meantime another image illustrates the call stack
    right before the crash (message not included).
    Note that for this application, we have the resouces loaded
    from a resource DLL. However, we were told that the help file was
    generated using these resource DLLs. We used this dialog as a
    testing platform because it is one of the simplest dialogs without
    the complexities of property pages etc., which do load certain
    dialog resources dynamically.
    However, to further test the problem, we implemented the
    context sensitive help on a more complex dialog using the standard
    HtmlHelp Api, where we are passing an array containing the mappings
    between the IDs and the Help topics (for now the mapping is fixed
    to one topic ID for simplicity) and I managed to make the context
    sensitive help work (not through the What's this menu but rather
    through the '?' button at the top right corner of the dialog.) The
    proper context help topic is displayed according to the mapped ID.
    Has anybody faced this problem and is there a solution for
    it? ;

    Unfortunately the update did not help. Using the field-level
    help in the dialog always ends up with a crash reporting the above
    error.
    The report generated from Microsoft's Windows XP is as
    follows:
    <?xml version="1.0" encoding="UTF-16"?>
    <DATABASE>
    <EXE NAME="HOBLinkL.exe"
    FILTER="GRABMI_FILTER_THISFILEONLY">
    <MATCHING_FILE NAME="HOBLinkL.exe" SIZE="466944"
    CHECKSUM="0xE180B629" BIN_FILE_VERSION="5.3.0.1"
    BIN_PRODUCT_VERSION="5.3.0.1" PRODUCT_VERSION="TE Version 5.3"
    FILE_DESCRIPTION="HOBLink Launcher" COMPANY_NAME="HOB GmbH
    &amp; Co KG" PRODUCT_NAME="HOBLink Terminal Edition"
    FILE_VERSION="5, 3, 0, 1" ORIGINAL_FILENAME="HOBLinkL.exe"
    INTERNAL_NAME="HOBLinkL" LEGAL_COPYRIGHT="Copyright © 2006,
    2007 - HOB GmbH &amp; Co. KG. All rights reserved."
    VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4"
    VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x5124E"
    LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="5.3.0.1"
    UPTO_BIN_PRODUCT_VERSION="5.3.0.1" LINK_DATE="01/29/2007 07:23:50"
    UPTO_LINK_DATE="01/29/2007 07:23:50" VER_LANGUAGE="English (United
    States) [0x409]" />
    </EXE>
    <EXE NAME="hhctrl.ocx"
    FILTER="GRABMI_FILTER_THISFILEONLY">
    <MATCHING_FILE NAME="hhctrl.ocx" SIZE="546304"
    CHECKSUM="0x38577544" BIN_FILE_VERSION="5.2.3790.2453"
    BIN_PRODUCT_VERSION="5.2.3790.2453" PRODUCT_VERSION="5.2.3790.2453"
    FILE_DESCRIPTION="Microsoft® HTML Help Control"
    COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="HTML Help"
    FILE_VERSION="5.2.3790.2453 (srv03_sp1_gdr.050525-1542)"
    ORIGINAL_FILENAME="HHCtrl.ocx" INTERNAL_NAME="HHCtrl 1.41"
    LEGAL_COPYRIGHT="© Microsoft Corporation. All rights
    reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0"
    VERFILEOS="0x40004" VERFILETYPE="0x1" MODULE_TYPE="WIN32"
    PE_CHECKSUM="0x8B1D0" LINKER_VERSION="0x50002"
    UPTO_BIN_FILE_VERSION="5.2.3790.2453"
    UPTO_BIN_PRODUCT_VERSION="5.2.3790.2453" LINK_DATE="05/27/2005
    02:04:27" UPTO_LINK_DATE="05/27/2005 02:04:27"
    VER_LANGUAGE="English (United States) [0x409]" />
    </EXE>
    <EXE NAME="kernel32.dll"
    FILTER="GRABMI_FILTER_THISFILEONLY">
    <MATCHING_FILE NAME="kernel32.dll" SIZE="983552"
    CHECKSUM="0x4CE79457" BIN_FILE_VERSION="5.1.2600.2180"
    BIN_PRODUCT_VERSION="5.1.2600.2180" PRODUCT_VERSION="5.1.2600.2180"
    FILE_DESCRIPTION="Windows NT BASE API Client DLL"
    COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft®
    Windows® Operating System" FILE_VERSION="5.1.2600.2180
    (xpsp_sp2_rtm.040803-2158)" ORIGINAL_FILENAME="kernel32"
    INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft
    Corporation. All rights reserved." VERFILEDATEHI="0x0"
    VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2"
    MODULE_TYPE="WIN32" PE_CHECKSUM="0xFF848" LINKER_VERSION="0x50001"
    UPTO_BIN_FILE_VERSION="5.1.2600.2180"
    UPTO_BIN_PRODUCT_VERSION="5.1.2600.2180" LINK_DATE="08/04/2004
    07:56:36" UPTO_LINK_DATE="08/04/2004 07:56:36"
    VER_LANGUAGE="English (United States) [0x409]" />
    </EXE>
    </DATABASE>
    Any other ideas how to solve this problem?

  • How can I make this code faster? optimized.

    Its part of two jsp pages that go back and forth. I feel I am creating new strings all of the time. I have 3 graphic representations of a radion button and a check box. its for a quiz program.
    if the button is not checked, it uses rd0.gif.
    if the button is checked, then its assigned rd1.gif.
    However, if the button is the wrong answer, then its assigned rd2.gif.
    the use of char arrays is neccasary, but not vital, I guess I could use indexof in the string. But I Dont know if its faster. I want to optimize the code, so it uses less resources.
    heres the code
    TrueFalse=entry[11].indexOf("TRUE");
    myButton = Integer.parseInt((String)session.getAttribute("BUTTONNO"));
    GivenAnswer =(String)session.getAttribute("GIVEN");
    if(TrueFalse==-1) {
    char[] questions = GivenAnswer.toCharArray();
    for(x=1;x<5;x++) {
    if(questions[x]=='1') { bp[x]="images/ck1.gif"; }else{ bp[x]="images/ck0.gif";}
    }else{
    if(myButton==1) {bp[1] = "images/rd1.gif";} else {bp[1] = "images/rd0.gif";}
    if(myButton==2) {bp[2] = "images/rd1.gif";} else {bp[2] = "images/rd0.gif";}
    questions is discarded.
    the quiz is fast at the begining, but once you go deeper and deeper it slows down. This is the second page:
    <%@ include file ="include4.jsp" %>
    <%
    session.setAttribute("BUTTONNO", "1");
    GivenAnswer =(String)session.getAttribute("GIVEN");
    char[] questions = GivenAnswer.toCharArray();
    questions[1]='1';
    tempString = new String (questions);
    GivenAnswer = tempString;
    session.setAttribute("GIVEN", GivenAnswer);
    %>
    <jsp:forward page="train2.jsp">
    </jsp:forward>
    I tried to keep all of the code on one page, but I am using images instead of real radio buttons, for several reasons. JSP doesnt seem to return a value for check/radio buttons in JSP, so clicking on an anchored image and going to a second JSP PAge seemed reasonable. I dont know how to force garbage collection. But the speed in which the pages and images appear, get slower and slower. so I Think im using up memory (Stings) at a greater rate than I should.
    thanks
    MIKe NIEMI
    [email protected]

    I'm not sure that an "optimisation" is necessarily what you're after. I doubt it's the creation of Strings that's causing any performance issue - even if it is then it's probably the result of something more sinister.
    Don't assume that your code is using a lot of resources.
    For example it's tempting to change it to this:
    if(myButton==1) {bp[1] = "images/rd1.gif";} else {bp[1] = "images/rd0.gif";}
    if(myButton==2) {bp[2] = "images/rd1.gif";} else {bp[2] = "images/rd0.gif";}
    // change to this?
    bp[myButton] = "images/rd1.gif";
    bp[3 - myButton] = "images/rd0.gif";I'd say that the original code was clearer and used just as many resources (once the Strings are interned).
    The same goes for this:
    if(questions[x]=='1') { bp[x]="images/ck1.gif"; }else{ bp[x]="images/ck0.gif";}
    // change to this?
    bp[x] = "images/ck" + questions[x] + ".gif";Again, the former is possibly clearer as it indicates that questions is really a boolean flag - it should also be easily optimised by the compiler.
    You're right that you could replace "questions" by simply using GivenAnswer.charAt(x).
    Enterprise Java applications can generate hundreds of thousands of Strings during their execution - your Servlet is unlikely to have a serious impact on that unless you've got an enormous loop in there or a very large user base.
    A golden rule of optimisation is not to assume that you know where the performance/resource bottlenecks are. Measure the improvement you get from a change - does it warrant the resultant increase in the complexity of the code?
    Put some profiling in your code - how long is it taking to run your Servlet? How many times is it being invoked? I can't imagine that the code you've provided will take more than a few milliseconds to run.
    Also, you can't force garbage collection. You can suggest it to the Java runtime (it might not even have a garbage collector!). However, this generally indicates a flaw in the application and should be avoided unless absolutely necessary (and it's not in this case!).
    If you really want to optimise then get hold of something like OptimizeIt - it will provide a great deal of information about what's being created and where.
    Hope this helps.

  • Just set up iTunes for windows but when I try to sync my iPhone to this it says I have another iTunes library on my power book. It than asks if I want to erase this iPhone and sync with this iTunes library. I used the same  library on the windows is blank

    Just set up iTunes for windows but when I try to sync my iPhone to it this is what it says, I have another iTunes library on my power book. It than asks if I want to erase this iPhone and sync with this iTunes library. I used the same password on this windows pc system same log on etc..I don't have anything loaded on it. All I want is for the info that's on the power book in iTunes and my iPhone to snyc/update etc on the windows pc.  How do I do this? My power book is dead to the world. 

    Read here.
    https://discussions.apple.com/message/18565125#18565125

  • How can I get rid of this Lollipop update?  My phone drains faster than it can take a charge!

    I've just spent 4 hours on the line w/ Verizon support agents who were all very nice, but nobody could solve my problem.  Without anything else happening on my phone, I hit an icon to launch an app, and it takes like 2 minutes for anything to happen.  The battery drains faster than it can get charged in SAFE MODE!
    Is there a way to go back to the old OS without rooting?

    Thanks.  I have been using the built-in battery monitor as well as the application manager.  It helps seeing the processes that are chewing away at your phone's RAM and battery, but at this point, it's not even helpful anymore.
    I don't think 'Samsung.Settings' is something I can disable on my phone and that is what's hogging up 80% of my phone's resources.  (Fresh boot and all)
    What really irks me is that I've never signed up to be a BETA tester for Samsung which is basically what we all are doing... Factory reset, remove all apps, add each app back individually, find what app(s) are causing the problems, etc.
    No - this should have been vetted out long before they decided to push out an OS update that has no backward motion of loading the previous OS...
    <Rant off>

  • Are the brushes in Photoshop CC faster than CS6 - still need to use CS5 for large files

    Hey,
    Are the brushes in Photoshop CC any faster than Photoshop CS6.
    Here's my standard large file, which makes the CS6 brushes crawl:
    iPad 3 size - 2048 x 1536
    About 20-100 layers
    A combination of vector and bitmap layers
    Many of the layers use layer styles
    On a file like this there is a hesitation to every brush stroke in CS6. Even a basic round brush has the same hesitation, it doesn't have to be a brush as elaborate as a mixer brush.
    This hesitation happens on both the mac and pc, on systems with 16 gb of ram. Many of my coworkers have the same issue.
    So, for a complicated file, such as a map with many parts, I ask my coworkers to please work in CS5. If they work in CS6 I ask them to not use any CS6 only features, such as group layer styles. The only reason why one of them might want to use CS6 is because they're working on only a small portion of the map, such as a building. The rest of the layers are flattened in their file.
    Just wondering if there has ever been a resolution to this problem...or this is just the way it is.
    Thanks for your help!

    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

Maybe you are looking for