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.
Similar Messages
-
How can I make my code more optimized?
This is the code for my android game I am trying to make:
import flash.events.MouseEvent;
import flash.media.SoundChannel;
import flash.display.MovieClip;
var STATE_INIT_GAME:String = "STATE_INIT_GAME";
var STATE_PLAY_GAME:String = "STATE_PLAY_GAME";
var STATE_END_GAME:String = "STATE_END_GAME";
var gameState:String;
var hearts:Array;
var atoms:Array;
var bombs:Array;
var enemies:Array;
var level:Number;
var score:Number;
var lives:Number;
var tempHeart:MovieClip;
var tempBomb:MovieClip;
var tempAtom:MovieClip;
var tempEnemy:MovieClip;
var rSound:rMusic = new rMusic ;
var Rchannel:SoundChannel;
var offset:int = 20;
var enemyBaseSpeed:int = 4;
var speedLevelInc:Number = 3;
var MAX_SPEED:Number = 100;
score = 0;
roachLevel.score_txt.text = String(score);
function gameLoopR(e:Event):void
switch (gameState)
case STATE_INIT_GAME :
initGame();
break;
case STATE_PLAY_GAME :
playGame();
break;
case STATE_END_GAME :
endGame();
break;
function initGame():void
Rchannel = rSound.play(0,9999);
level = 1;
roachLevel.level_txt.text = String(level);
lives = 3;
roachLevel.lives_txt.text = String(lives);
hearts = new Array();
bombs = new Array();
atoms = new Array();
enemies = new Array();
gameState = STATE_PLAY_GAME;
function playGame():void
makeEnemies();
moveEnemies();
makeHearts();
moveHearts();
makeBombs();
moveBombs();
makeAtoms();
moveAtoms();
testForEnd();
function makeBombs():void
var chance:Number = Math.floor(Math.random() * 6000);
if (chance <= + level)
tempBomb.scaleX = 1.5;
tempBomb.scaleY = 1.5;
tempBomb = new Bomb();
tempBomb.x = Math.round(Math.random() * 480);
tempBomb.cacheAsBitmap = true;
addChild(tempBomb)
bombs.push(tempBomb);
tempBomb.speed = 1;
function moveBombs():void
var tempBomb:MovieClip;
for (var h:int =bombs.length-1; h>=0; h--)
tempBomb = bombs[h];
if (tempBomb.dead)
Rchannel.stop();
lives = 0;
roachLevel.level_txt.text = String(lives);
bombs.splice(h,1);
else
tempBomb.rotation += (Math.round(Math.random()*.4));
tempBomb.y += (Math.cos((Math.PI/180)*tempBomb.rotation))*tempBomb.speed;
if (tempBomb.x < 10)
tempBomb.x = 11;
if (tempBomb.x > stage.stageWidth - offset)
tempBomb.x = stage.stageWidth - offset;
if (tempBomb.y > stage.stageHeight)
removeBomb(h);
function makeEnemies():void
var chance:Number = Math.floor(Math.random() * 150);
if (chance <= level && enemies.length < 4)
tempEnemy = new Enemy();
tempEnemy.x = Math.round(Math.random() * 480);
tempEnemy.cacheAsBitmap = true;
addChild(tempEnemy);
tempEnemy.scaleX = 1.5;
tempEnemy.scaleY = 1.5;
enemies.push(tempEnemy);
tempEnemy.speed = enemyBaseSpeed + ((level - 1) * speedLevelInc);
if (tempEnemy.speed > MAX_SPEED)
tempEnemy.speed = MAX_SPEED;
function moveEnemies():void
var tempEnemy:MovieClip;
for (var i:int =enemies.length-1; i>=0; i--)
tempEnemy = enemies[i];
if (tempEnemy.dead)
score++;
score++;
roachLevel.score_txt.text = String(score);
enemies.splice(i,1);
else
tempEnemy.rotation += (Math.round(Math.random()*.4));
tempEnemy.y += (Math.cos((Math.PI/180)*tempEnemy.rotation))*tempEnemy.speed;
if (tempEnemy.x < 10)
tempEnemy.x = 11;
if (tempEnemy.x > stage.stageWidth - offset)
tempEnemy.x = stage.stageWidth - offset;
if (tempEnemy.y > stage.stageHeight)
removeEnemy(i);
lives--;
roachLevel.lives_txt.text = String(lives);
function makeHearts():void
var chance:Number = Math.floor(Math.random() * 8000);
if (chance <= + level)
tempHeart = new Heart();
tempHeart.x = Math.round(Math.random() * 480);
tempHeart.cacheAsBitmap = true;
addChild(tempHeart);
tempHeart.scaleX = 1.5;
tempHeart.scaleY = 1.5;
hearts.push(tempHeart);
tempHeart.speed = enemyBaseSpeed + ((level - 1) * speedLevelInc);
function moveHearts():void
var tempHeart:MovieClip;
for (var k:int =hearts.length-1; k>=0; k--)
tempHeart = hearts[k];
if (tempHeart.dead)
lives++;
roachLevel.lives_txt.text = String(lives);
hearts.splice(k,1);
else
tempHeart.rotation += (Math.round(Math.random()*.4));
tempHeart.y += (Math.cos((Math.PI/180)*tempHeart.rotation))*tempHeart.speed;
if (tempHeart.x < 10)
tempHeart.x = 11;
if (tempHeart.x > stage.stageWidth - offset)
tempHeart.x = stage.stageWidth - offset;
if (tempHeart.y > stage.stageHeight)
removeHeart(k);
function makeAtoms():void
var chance:Number = Math.floor(Math.random() * 7500);
if (chance <= + level)
tempAtom = new Atom();
tempAtom.x = Math.round(Math.random() * 480);
tempAtom.cacheAsBitmap = true;
addChild(tempAtom);
tempAtom.scaleX = 1.5;
tempAtom.scaleY = 1.5;
atoms.push(tempAtom);
tempAtom.speed = enemyBaseSpeed + ((level - 1) * speedLevelInc);
function moveAtoms():void
var tempAtom:MovieClip;
for (var c:int =atoms.length-1; c>=0; c--)
tempAtom = atoms[c];
if (tempAtom.dead)
score++;
score++;
score++;
score++;
score++;
roachLevel.score_txt.text = String(score);
atoms.splice(c,1);
else
tempAtom.rotation += (Math.round(Math.random()*.4));
tempAtom.y += (Math.cos((Math.PI/180)*tempAtom.rotation))*tempAtom.speed;
if (tempAtom.x < 10)
tempAtom.x = 11;
if (tempAtom.x > stage.stageWidth - offset)
tempAtom.x = stage.stageWidth - offset;
if (tempAtom.y > stage.stageHeight)
removeAtom(c);
function removeEnemy(id:int)
removeChild(enemies[id]);
enemies.splice(id,1);
function removeHeart(kd:int)
removeChild(hearts[kd]);
hearts.splice(kd,1);
function removeBomb(hd:int)
removeChild(bombs[hd]);
bombs.splice(hd,1);
function removeAtom(cd:int)
removeChild(atoms[cd]);
atoms.splice(cd,1);
function testForEnd():void
if (score > level * 20)
level++;
roachLevel.level_txt.text = String(level);
if (lives == 0)
gameState = STATE_END_GAME;
function endGame():void
removeGame();
roachLevel.visible = false;
Menu_mc.visible = false;
endscreen_mc.visible = true;
removeEventListener(Event.ENTER_FRAME, gameLoopR);
showresults();
function removeGame():void
for (var i:int = enemies.length-1; i >=0; i--)
removeEnemy(i);
for (var h:int = bombs.length-1; h >=0; h--)
removeBomb(h);
for (var k:int = hearts.length-1; k >=0; k--)
removeHeart(k);
for (var c:int = atoms.length-1; c >=0; c--)
removeAtom(c);
The game works perfectly on Android and everything works. There is one problem though. The game gets laggy and the enemies get harder to click when the enemies' speed increases. This is the code for the enemies. It is a movie clip that gets added on to the stage by actionscript.
import flash.events.MouseEvent;
import flash.display.MovieClip;
import fl.motion.Animator;
import flash.events.*;
play();
var mysound:squish = new squish();
this.addEventListener(MouseEvent.CLICK, kill);
this.dead = false;
function kill(e:MouseEvent):void
this.dead=true;
mouseChildren=false
mysound.play();
gotoAndPlay(21);
this.removeEventListener(MouseEvent.CLICK, kill);
flash.utils.setTimeout(removeSelf,2000);
function removeSelf():void
this.parent.removeChild(this);no,
var identityMatrix:Matrix=new Matrix()
my_sprite.cacheAsBitmapMatrix=identityMatrix;
though for tempAtom,
var scaleMatrix:Matrix=identityMatrix.scale(1.5,1.5); //would be appropriate.
you can get a cc trial, http://gaming.adobe.com/technologies/scout/ -
After updating to mavericks on my MacBook, the screen keeps saying "setting up your mac." It has been like this for hours! How can I make it go faster? It's has been like this for 4 hrs.
I don't think your mac is setting up. It's stuck.
I would:
hold the power button until it shuts down
unplug all peripherals
do a safe boot (restart and hold down the shift key until you see the apple logo).
If it starts up in a safe boot, then you can try restarting with a normal boot.
If it does not start with a normal boot, then you probably have some incompatible third party software. Likely culprits are:
MacKeeper
CleanMyMac
third-party antivirus software
any other "cleaning" or "optimizing" or similar third party "utilities".
A good place to start would be to uninstall any of those (while in safe mode) and then restart. -
How can I make Privoxy load faster?
I'm using vimb and it works well except the only way to block ads is to use privoxy. Privoxy takes about 5-10 minutes to start after my computer boots. This means I can't access the internet when I first start my computer. How can I make it load faster?
https://wiki.archlinux.org/index.php/Hostsblock
https://aur.archlinux.org/packages/hostsblock/
Also e.g. https://aur.archlinux.org/packages/hosts-update/ -
How can I make this join in ADF and make CRUD operation in this
How to make this relation in ADF
I have table employees and this is my master table
Table Name: Employees
Columns:
Employee_id(PK)
Employee_name
Employee_Salary
I have a child table that is called related employee that contains employees related to this employee
Table_name: Related_Employee
Columns:
Related_Employee_Table_Id(PK)
Employee_id(FK)
Related_Employee_Id
When I open employee id = 100 for example and add related employee id = 10
this is added with no problem but the requirement is that when I open employee 10 I find employee id 100 as related employee
How can I make this scenario.The best way to understand this is to look at an example. If you are using an oracle database such as XE for you have a schema called hr. This shema has a number of tables two of which are departments and employees. a department has multiple employees correct. So in your example a employee may be related to x # of other employees perhaps. A very similar scenario as that in the hr Schema. If you don't have an Oracle XE database, download one from here -> http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
Create Business Components off of the Departments and Employees schema and you'll see that due to the db design, you get what you're talking about for free (i.e. the join). Thus, you have the master-detail relationship you're looking for. For a quick tip, here is the relationship between departments and employees in the hr schema via a create script that you can exam with data inserts included:
SET SQLBLANKLINES ON
CREATE TABLE DEPARTMENTS
DEPARTMENT_ID NUMBER(4, 0) NOT NULL
, DEPARTMENT_NAME VARCHAR2(30 BYTE) NOT NULL
, MANAGER_ID NUMBER(6, 0)
, LOCATION_ID NUMBER(4, 0)
, CONSTRAINT DEPT_ID_PK PRIMARY KEY
DEPARTMENT_ID
USING INDEX
CREATE UNIQUE INDEX DEPT_ID_PK ON DEPARTMENTS (DEPARTMENT_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE TABLE EMPLOYEES
EMPLOYEE_ID NUMBER(6, 0) NOT NULL
, FIRST_NAME VARCHAR2(20 BYTE)
, LAST_NAME VARCHAR2(25 BYTE) NOT NULL
, EMAIL VARCHAR2(25 BYTE) NOT NULL
, PHONE_NUMBER VARCHAR2(20 BYTE)
, HIRE_DATE DATE NOT NULL
, JOB_ID VARCHAR2(10 BYTE) NOT NULL
, SALARY NUMBER(8, 2)
, COMMISSION_PCT NUMBER(2, 2)
, MANAGER_ID NUMBER(6, 0)
, DEPARTMENT_ID NUMBER(4, 0)
, CONSTRAINT EMP_EMP_ID_PK PRIMARY KEY
EMPLOYEE_ID
USING INDEX
CREATE UNIQUE INDEX EMP_EMP_ID_PK ON EMPLOYEES (EMPLOYEE_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX DEPT_LOCATION_IX ON DEPARTMENTS (LOCATION_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_DEPARTMENT_IX ON EMPLOYEES (DEPARTMENT_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_JOB_IX ON EMPLOYEES (JOB_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_MANAGER_IX ON EMPLOYEES (MANAGER_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_NAME_IX ON EMPLOYEES (LAST_NAME ASC, FIRST_NAME ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_EMAIL_UK UNIQUE
EMAIL
USING INDEX
CREATE UNIQUE INDEX EMP_EMAIL_UK ON EMPLOYEES (EMAIL ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_LOC_FK FOREIGN KEY
LOCATION_ID
REFERENCES LOCATIONS
LOCATION_ID
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_MGR_FK FOREIGN KEY
MANAGER_ID
REFERENCES EMPLOYEES
EMPLOYEE_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_DEPT_FK FOREIGN KEY
DEPARTMENT_ID
REFERENCES DEPARTMENTS
DEPARTMENT_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_JOB_FK FOREIGN KEY
JOB_ID
REFERENCES JOBS
JOB_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_MANAGER_FK FOREIGN KEY
MANAGER_ID
REFERENCES EMPLOYEES
EMPLOYEE_ID
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_NAME_NN CHECK
(DEPARTMENT_NAME IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_EMAIL_NN CHECK
(EMAIL IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_HIRE_DATE_NN CHECK
(HIRE_DATE IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_JOB_NN CHECK
(JOB_ID IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_LAST_NAME_NN CHECK
(LAST_NAME IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_SALARY_MIN CHECK
(SALARY > 0)
ENABLE;
COMMENT ON TABLE DEPARTMENTS IS 'Departments table that shows details of departments where employees
work. Contains 27 rows; references with locations, employees, and job_history tables.';
COMMENT ON TABLE EMPLOYEES IS 'employees table. Contains 107 rows. References with departments,
jobs, job_history tables. Contains a self reference.';
COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_ID IS 'Primary key column of departments table.';
COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_NAME IS 'A not null column that shows name of a department. Administration,
Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public
Relations, Sales, Finance, and Accounting. ';
COMMENT ON COLUMN DEPARTMENTS.MANAGER_ID IS 'Manager_id of a department. Foreign key to employee_id column of employees table. The manager_id column of the employee table references this column.';
COMMENT ON COLUMN DEPARTMENTS.LOCATION_ID IS 'Location id where a department is located. Foreign key to location_id column of locations table.';
COMMENT ON COLUMN EMPLOYEES.EMPLOYEE_ID IS 'Primary key of employees table.';
COMMENT ON COLUMN EMPLOYEES.FIRST_NAME IS 'First name of the employee. A not null column.';
COMMENT ON COLUMN EMPLOYEES.LAST_NAME IS 'Last name of the employee. A not null column.';
COMMENT ON COLUMN EMPLOYEES.EMAIL IS 'Email id of the employee';
COMMENT ON COLUMN EMPLOYEES.PHONE_NUMBER IS 'Phone number of the employee; includes country code and area code';
COMMENT ON COLUMN EMPLOYEES.HIRE_DATE IS 'Date when the employee started on this job. A not null column.';
COMMENT ON COLUMN EMPLOYEES.JOB_ID IS 'Current job of the employee; foreign key to job_id column of the
jobs table. A not null column.';
COMMENT ON COLUMN EMPLOYEES.SALARY IS 'Monthly salary of the employee. Must be greater
than zero (enforced by constraint emp_salary_min)';
COMMENT ON COLUMN EMPLOYEES.COMMISSION_PCT IS 'Commission percentage of the employee; Only employees in sales
department elgible for commission percentage';
COMMENT ON COLUMN EMPLOYEES.MANAGER_ID IS 'Manager id of the employee; has same domain as manager_id in
departments table. Foreign key to employee_id column of employees table.
(useful for reflexive joins and CONNECT BY query)';
COMMENT ON COLUMN EMPLOYEES.DEPARTMENT_ID IS 'Department id where employee works; foreign key to department_id
column of the departments table'; -
How can i improve this code ?
DATA: t_bkpf TYPE bkpf.
DATA: t_bseg type bseg_t.
DATA: wa_bseg like line of t_bseg.
select * from bkpf into t_bkpf where document type ='KZ' and bldat in s_bldat.
select single * from bseg into wa_bseg where belnr = t_bkpf-belnr.
append wa_bseg to t_bseg.
endselect.
loop at t_bseg into wa_bseg.
at new belnr.
if wa_bseg-koart EQ 'K'.
// pick vendor wrbtr
else
// pick other line item's wrbtr
endif.
endat.
endloop.
i am guessing my select statements arnt efficient performance wise, secondly in the loop when i use 'at new belnr' it aint showing my any values whereas i get all the vendors(KOART EQ 'K') when i dont use 'at new belnr' .
why is this so and how can i make the code efficient ?
Thanks..
ShehryarHi,
1.Dont read all the fields from the table unless it is required in your program.
This will tremendously improve your performance.
2.Make use of the key fields of the table wherever possible
In your scenario you could use the fields BUKRS,BELNR,GJAHR of the table BKPF in the WHERE Clause rather than
other fields.This will improve your performance a lot..
3.As BSEG is a cluster table it will cause performance problem in most cases.So try to read
the required fields from it rather than reading all the fields.Again Make use of the key fields in the WHERE Clause
here too to improve the performance..
4.Remove SELECT..ENDSELECT and replace it with FOR ALL ENTRIES to improve the performance.
Cheers,
Abdul Hakim
Mark all useful answers.. -
How can i know how to redeem the code? how can i get this code?
how can i know how to redeem the code? how can i get this code? please i need you help
<Email Edited by Host>You are trying to create a new Apple ID? You don't have one yet? Is that correct?
If so, then see this article on how to creat your Apple ID - and make up a password for it. Remember to write it down immediately.
http://support.apple.com/en-us/HT203993 -
How can i rewrite this code into java?
How can i rewrite this code into a java that has a return value?
this code is written in vb6
Private Function IsOdd(pintNumberIn) As Boolean
If (pintNumberIn Mod 2) = 0 Then
IsOdd = False
Else
IsOdd = True
End If
End Function
Private Sub cmdTryIt_Click()
Dim intNumIn As Integer
Dim blnNumIsOdd As Boolean
intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
blnNumIsOdd = IsOdd(intNumIn)
If blnNumIsOdd Then
Print "The number that you entered is odd."
Else
Print "The number that you entered is not odd."
End If
End Sub873221 wrote:
I'm sorry I'am New to Java.Are you new to communication? You don't have to know anything at all about Java to know that "I have an error," doesn't say anything useful.
I'm just trying to get you to think about what your post actually says, and what others will take from it.
what does this error mean? what code should i replace and add? thanks for all response
C:\EvenOdd.java:31: isOdd(int) in EvenOdd cannot be applied to ()
isOdd()=true;
^
C:\EvenOdd.java:35: isOdd(int) in EvenOdd cannot be applied to ()
isOdd()=false;
^
2 errors
Telling you "what code to change it to" will not help you at all. You need to learn Java, read the error message, and think about what it says.
It's telling you exactly what is wrong. At line 31 of EvenOdd.java, you're calling isOdd(), with no arguments, but the isOdd() method requires an int argument. If you stop ant think about it, that should make perfect sense. How can you ask "is it odd?" without specifying what "it" is?
So what is this all about? Is this homework? You googled for even odd, found a solution in some other language, and now you're just trying to translate it to Java rather than actually learning Java well enough to simply write this trivial code yourself? -
I have an ipad mini. From one moment to another a document that was created and used on pages app ( on the ipad mini) does not want to open ( When pressed it states " document cant be opened). How can I make this document open again?
I have tried back ups and restoring, resetting, and even updating the pages app. And nothing has worked.I have an ipad mini. From one moment to another a document that was created and used on pages app ( on the ipad mini) does not want to open ( When pressed it states " document cant be opened). How can I make this document open again?
I have tried back ups and restoring, resetting, and even updating the pages app. And nothing has worked. -
How do I make this code generate a new pro when the "NEXT" button is pushed
How do I make this code generate a new set of problem when the "NEXT" Button is pushed
* To change this template, choose Tools | Templates
* and open the template in the editor.
/* Figure out how to create a new set of problms
* Type a list of specifications, include a list of test cases
* DONE :]
package javaapplication1;
import java.awt.GridLayout;
import java.awt.Window;
import javax.swing.*;
import java.awt.event.*;
* @author Baba Akinlolu -
class Grid extends JFrame{
int done = 0;
final int score = 0;
final int total = 0;
//Create Panels
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
final JPanel p1 = new JPanel();
//Create Radio buttons & group them
ButtonGroup group = new ButtonGroup();
final JRadioButton ADD = new JRadioButton("Addition");
final JRadioButton SUB = new JRadioButton("Subtraction");
final JRadioButton MUL = new JRadioButton("Multiplication");
final JRadioButton DIV = new JRadioButton("Division");
//Create buttons
JButton NEXT = new JButton("NEXT");
JButton END = new JButton("End");
//Create Labels
JLabel l1 = new JLabel("First num");
JLabel l2 = new JLabel("Second num");
JLabel l3 = new JLabel("Answer:");
JLabel l4 = new JLabel("Score:");
final JLabel l5 = new JLabel("");
JLabel l6 = new JLabel("/");
final JLabel l7 = new JLabel("");
//Create Textfields
final JTextField number = new JTextField(Generator1());
final JTextField number2 = new JTextField(Generator1());
final JTextField answer = new JTextField(5);
Grid(){
setLayout(new GridLayout(4, 4, 2 , 2));
p2.add(ADD);
p2.add(SUB);
group.add(ADD);
group.add(SUB);
group.add(MUL);
group.add(DIV);
p2.add(ADD);
p2.add(SUB);
p2.add(DIV);
p2.add(MUL);
//Add to panels
p1.add(l1);
p1.add(number);
p1.add(l2);
p1.add(number2);
p1.add(l3);
p1.add(answer);
p1.add(l4);
p1.add(l5);
p1.add(l6);
p1.add(l7);
p3.add(NEXT);
p3.add(END);
//Add panels
add(p2);
add(p1);
add(p3);
//Create Listners
Listeners();
void Listeners(){
NEXT.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int answer1 = 0;
//Grab the numbers entered
int numm1 = Integer.parseInt(number.getText());
int numm2 = Integer.parseInt(number2.getText());
int nummsanswer = Integer.parseInt(answer.getText());
//Set the score and total into new variabls
int nummscore = score;
int nummtotal = total;
//Check if the add radio button is selected if so add
if (ADD.isSelected() == true){
answer1 = numm1 + numm2;
//otherwise check if the subtract button is selected if so subtract
else if (SUB.isSelected() == true){
answer1 = numm1 - numm2;
//check if the multiplication button is selected if so multiply
else if (MUL.isSelected() == true){
answer1 = numm1 * numm2;
//check if the division button is selected if so divide
else if (DIV.isSelected() == true){
answer1 = numm1 / numm2;
//If the answer user entered is the same with th true answer
if (nummsanswer == answer1){
//add to the total and score
nummtotal += 1;
nummscore += 1;
//Convert the input back to String
String newscore = String.valueOf(nummscore);
String newtotal = String.valueOf(nummtotal);
//Set the text
l5.setText(newscore);
l7.setText(newtotal);
//Otherwise just increase the total counter
else {
nummtotal += 1;
String newtotal = String.valueOf(nummtotal);
l7.setText(newtotal);
//Create End listener
END.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// get the root window and call dispose on it
Window win = SwingUtilities.getWindowAncestor(p1);
win.dispose();
//new Grid();
String Generator1(){
int randomnum;
randomnum = (1 + (int)(Math.random() * 100));
String randomnumm = String.valueOf(randomnum);
return randomnumm;
public class Main {
* @param args the command line arguments
public static void main(String[] args) {
// TODO code application logic here
JFrame frame = new Grid();
frame.setTitle("Flashcard Testing");
frame.setSize(500, 200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}Edited by: SirSaula on Dec 7, 2009 10:17 AMNot only are you continuing to post in the wrong forum but now you are multiposting: [http://forums.sun.com/thread.jspa?threadID=5418935]
If people haven't answered you other posting its probably because we don't understand the question. Quit cluttering the forum by asking the same question over and over and then next time you have a new question post it in the proper forum. Your first posting was moved becuase you didn't post it properly. -
I keep Mail open on my MacBook Pro and prior to Mavericks items would open on my 27" secondary display. How can I make this happen in Mavericks?
In System Preferences > Mission Control, uncheck mark Displays have seperate windows. This should bring you back to the secondary display you had before the upgrade. You may have to open Mail, the first time and place it on your secondary display. You also won't have the advantages of the dock and menus on the secondary display.
I keep my own secondary display with these settings because I need the ability to expand a window across both displays. -
When filling out a form, some fields copy to others when I tab to the next. How can I make this stop?
You can't using Adobe Reader. It looks like whomever created the form used the same identifiers (names) for various fields. Each field with the same name will populate with the information used in another field of the same name. This is intentional.
Normally when I see this, it tells me that someone created an initial field then copy/pasted it to make additional fields but forgot to change the names. -
Just restored my iPhone 5 from iCloud. My wife and I have always shared one iCloud ID. But since my restore, when a call comes in, it rings on both my phone and hers. How can I make this stop? We had it all set up fine before the restore, and there was a trick to it in the settings. I've noticed that since my restore, her phone has picked up what looks like the symbol of a phone in the upper right corner of the display, right next to the Bluetooth symbol.
Hi Big Slick,
Welcome to the Apple Support Community!
It sounds like your iPhones may be using a new feature in iOS 8 called Continuity. The following article and information explains how to set up this feature for phone calls. You can review the information on the setup to reverse this effect. My suggestion would be to turn off FaceTime on one of the devices.
Connect your iPhone, iPad, iPod touch, and Mac using Continuity
Phone calls
With Continuity, you can make and receive cellular phone calls from your iPad, iPod touch, or Mac when your iPhone is on the same Wi-Fi network.
To make and receive phone calls, here's what you need:
Sign in to the same iCloud account on all your devices, including your Mac.
Your iPhone and your iPad or iPod touch need to use iOS 8 or later. Your Mac needs to use OS X Yosemite.
All devices must be on the same Wi-Fi network.
All devices must be signed in to FaceTime using the same iCloud account. This means any device that shares your Apple ID will get your phone calls. Look below for instructions on how to turn off iPhone cellular calls.
Wi-Fi Calling needs to be off. Go to Settings > Phone. If you see Wi-Fi Calling, turn it off.
Cheers,
Joe -
Whenever I open my browser, the check plugins page keeps opening, even after I have updated all of my plugins.
How can I make this stop?That is a bug with blocklisting plugins that has been fixed.<br />
You can correct this issue by forcing the file blocklist.xml to update or wait until Firefox updates the file.<br />
That update will remove the severity="0" flags in the file that cause the problem.
See:
* [/questions/832793?page=2#answer-198407]
* http://forums.mozillazine.org/viewtopic.php?p=10899869#p10899869
* [https://bugzilla.mozilla.org/show_bug.cgi?id=663722 Bug 663722] - The blocklist output is including severity="0" where it shouldn't be -
My Macbook Pro has become very slow and it sometimes hangs. How can I make it work faster and normal? I used Etrecheck and got the report below;
EtreCheck version: 1.9.12 (48)
Report generated June 16, 2014 at 18:05:25 GMT+1
Hardware Information:
MacBook Pro (13-inch, Mid 2012) (Verified)
MacBook Pro - model: MacBookPro9,2
1 2.5 GHz Intel Core i5 CPU: 2 cores
4 GB RAM
Video Information:
Intel HD Graphics 4000 - VRAM: (null)
Color LCD 1280 x 800
System Software:
OS X 10.9.3 (13D65) - Uptime: 0 days 1:50:52
Disk Information:
APPLE HDD TOSHIBA MK5065GSXF disk0 : (500.11 GB)
EFI (disk0s1) <not mounted>: 209.7 MB
Machintosh HD (disk0s2) / [Startup]: 499.25 GB (465.33 GB free)
Recovery HD (disk0s3) <not mounted>: 650 MB
MATSHITADVD-R UJ-8A8
USB Information:
Apple Inc. FaceTime HD Camera (Built-in)
Apple Inc. Apple Internal Keyboard / Trackpad
Apple Inc. BRCM20702 Hub
Apple Inc. Bluetooth USB Host Controller
Apple Computer, Inc. IR Receiver
Thunderbolt Information:
Apple Inc. thunderbolt_bus
Gatekeeper:
Mac App Store and identified developers
Launch Daemons:
[loaded] com.adobe.fpsaud.plist Support
[loaded] com.microsoft.office.licensing.helper.plist Support
User Login Items:
iTunesHelper
Dr.Web Light
Dropbox
Internet Plug-ins:
SharePointBrowserPlugin: Version: 14.0.0 Support
FlashPlayer-10.6: Version: 14.0.0.125 - SDK 10.6 Support
Flash Player: Version: 14.0.0.125 - SDK 10.6 Support
QuickTime Plugin: Version: 7.7.3
Default Browser: Version: 537 - SDK 10.9
Safari Extensions:
iGetter Extension: Version: 2.9.2
Audio Plug-ins:
BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
AirPlay: Version: 2.0 - SDK 10.9
AppleAVBAudio: Version: 203.2 - SDK 10.9
iSightAudio: Version: 7.7.3 - SDK 10.9
iTunes Plug-ins:
Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
User Internet Plug-ins:
iGetter Plugin: Version: 2.9.2 Support
iGetterScriptablePlugin: Version: 2.9.2 Support
3rd Party Preference Panes:
Flash Player Support
Time Machine:
Time Machine not configured!
Top Processes by CPU:
4% Dropbox
3% WindowServer
0% fontd
0% Microsoft Word
0% Microsoft Excel
Top Processes by Memory:
242 MB drwebd
176 MB Dropbox
147 MB Dr.Web Light
86 MB WindowServer
82 MB App Store
Virtual Memory Information:
43 MB Free RAM
1.68 GB Active RAM
1.65 GB Inactive RAM
641 MB Wired RAM
421 MB Page-ins
0 B Page-outsMeli070,
uninstall Dr.Web Light.
Maybe you are looking for
-
Simple as that. Given that I have OCD, it's extremely unpleasant to have both the forward and back buttons not consistently visible. How can I return to that appearance? I also want to separate the reload button from the location bar, as I had it bef
-
I I bought an iphone 4s factory unlocked. Can i set it up with my sim card in canada then take it out and bring the phone to iran without any problems?
-
Studio 12: dbx: internal error: signal SIGSEGV (no mapping at the fault add
$dbx /usr/bin/dbx /tmp/core For information about new features see `help changes' To remove this message, put `dbxenv suppress_startup_message 7.6' in your .dbxrc Reading dbx core file header read successfully Reading ld.so.1 Reading libintl.so.1 Rea
-
Display is dead, how do I find if I have that nasty NVIDIA card???
Well, my laptop went out of warranty 2.5 weeks ago. Monday night I was using my computer just fine. Tuesday morning went to it and the display was dead. I checked the brightness, tried booting in different ways, and will try the PRAM and SMC clearing
-
Performa invoice for delivery Doc
Hi, I want to know the steps to create performa invoice for delivery doc. Regards, Supriya.