AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Why my java code is THAT slow compared too C++?
Goto page Previous  1, 2, 3, ... 330, 331, 332  Next
 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming
View previous topic :: View next topic  
Author Message
geletine
Guest





PostPosted: Sun Feb 12, 2006 12:41 am    Post subject: Re: For loop Reply with quote



Hello

Quote:
So did the spec say that you have to prompt for the number
of students or did you figure that would be the best solution?

It would make sense to ask for a users grade and then ask if they want
another and then when they don;t to exit the loop, but unfortunately i
have to determine the amount of grades to be entered first.

Quote:
If on the other hand you want to print the total number of students who
passed or failed you aren't capturing enough information inside the loop.

that is what i am been assigned to do.

I have hopefully arranged the pseudocode slightly better now..

Read the number of students
Start loop
Read a number for the first student
Student total grades = Student total grades + student grade
End loop
Calculate average grade for the students
If the student grade is greater than 60
calculate how many students got grades 60 and above ??
Else
calculate how many students got grades 59 and below??

Print to the screen total amount of students
Print to the screen the average grade
Print to the screen the amount of students that have passed
print to the screen the amount of students that have failed


i believe with some thought that i am on the right side of road..
Back to top
Bill Cunningham
Guest





PostPosted: Sun Feb 12, 2006 1:35 am    Post subject: Re: applet build Reply with quote



"Thomas Fritsch" <i.dont.like.spam (AT) invalid (DOT) com> wrote in message
news:dsjgt0$g95$02$1 (AT) news (DOT) t-online.com...
Quote:
"Bill Cunningham" <nospam (AT) nspam (DOT) com> wrote:
"Douwe" <dmvos2000 (AT) yahoo (DOT) com> wrote:
If it is the second then you should realy use Ant or download the
binaries.

I can't find any binaries. Only the source.

Go to http://ant.apache.org/ -> binary distributions --> ...
Download "...-bin.zip" (not "...-src.zip").

--
"TFritsch$t-online:de".replace(':','.').replace('$','@')

I mean the binaries for the Jgui applet.

Bill
Back to top
Roedy Green
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: Multithreading / Scalability Reply with quote



On 11 Feb 2006 18:51:06 GMT, blmblm (AT) myrealbox (DOT) com wrote, quoted or
indirectly quoted someone who said :

Quote:
I can believe that in current operating systems it's almost as fast
to create processes as to create threads.

nowhere near as fast, especially if you start several threads using
the same classes. The classes are already loaded so there is little to
do other than allocate some ram for a stack.

With an external process you must load a partly compressed exe file,
and relocate all the addresses in it, and hook up all the DLLs, then
you can think about loading the DLLs.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Back to top
Tom Leylan
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: For loop Reply with quote

"geletine" <adaviscg1 (AT) hotmail (DOT) com> wrote...

Quote:
It would make sense to ask for a users grade and then ask if they want
another and then when they don;t to exit the loop, but unfortunately i
have to determine the amount of grades to be entered first.

Good enough reason, I just wanted to make sure :-)

Quote:
Read the number of students
Start loop
Read a number for the first student
Student total grades = Student total grades + student grade
End loop
Calculate average grade for the students
If the student grade is greater than 60
calculate how many students got grades 60 and above ??
Else
calculate how many students got grades 59 and below??

Print to the screen total amount of students
Print to the screen the average grade
Print to the screen the amount of students that have passed
print to the screen the amount of students that have failed

i believe with some thought that i am on the right side of road..

I think you are definitely closer. This line: "If the student grade is
greater than 60" is still suspect. Again if you mean the last student
entered it would work but that is a very odd spec for a school project.
Seriously you could post the assignment and we can figure out the
pseudocode. Notice you are actually "ahead" in the process. At first you
were trying to write a Java app without knowing the goal. At least now you
can reword the thing repeatedly without bothering with Java syntax. Resist
the temptation to start coding before you have a defined target. Is 60 the
passing grade? Is the assignment to use a for loop or can you use any type
of loop?

Look the following over. Note that I try to avoid things like "to the
screen", "calculate average" and even "if student grade is greater than 60"
because your first pass needn't include that kind of detail. I will output
the studentAverage so it infers I will need to calculate it. I don't need
to calculate it anywhere in particular however perhaps I can do it inline
when I output it. I don't exactly know what constitutes passed or failed
either. It will be 60 but for me to outline routine doesn't require that
information. Something will determine it but what I need to do is keep
track of the total.

// get studentCount
// while counter < studentCount
// get grade
// total passedCount
// total failedCount
// total gradeTotal
// end

// output studentCount
// output studentAverage
// output passedCount
// output failedCount

Is this what you want it to do? If so do you want to try the next step?
Create a Java app and place the pseudocode in a method. Notice I made them
comments so you can imbed them in your routine. I probably wouldn't put
place it directly in main or all you get is an app which can compute this
one thing. Yes I know that is the assignment but why not create a framework
that the next assignment can use also? Have your main method can call
getGrades() or something like that.

In any case define and initialize the count variables you need (not the loop
ones yet). Add the output lines (in Java) and have them output the proper
variables. Now compile and run and lo and behold it should produce your
output. The numbers will all be zero but hey you're part way there. If
there are no errors you proceed to step two. Add the code to input the
studentCount. Compile and run it again. Still working, great go on to step
3. Add a line to input a grade... you still don't need the loop. Compile
and run. Notice how if at any time it stops working you can look over what
you just did. There won't be 50 lines of Java to hunt through there will be
the 4 or 5 you just added.

So now add the loop. If the output worked in step 1 and the input worked in
steps 2 and 3 then I'm going to guess there are no surprises and the entire
thing works as expected.

Let us see the final results and gosh I hope it is prettier than the first
one Smile Don't forget to make the pass/fail value a constant (static final).
You don't want magic numbers like 60 appearing in the middle of your code.

Hope this helps,
Tom
Back to top
ossie.moore@gmail.com
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: How to deploy Java Applications To People W/O Having To Reply with quote

btw.. The point of regenerating once every two minutes is to
demonstrate the auto-update aspect. Once you click on the link once,
and launch the do nothing app, click again quickly, you'll note it
loads from local disk. Wait a couple minutes, click on the link again,
it will be reloaded from the webstie as it as been updated. But it
won't download unelss the webserver version has updates.
Back to top
ossie.moore@gmail.com
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: How to deploy Java Applications To People W/O Having To Reply with quote

Here is an example... This launches a full blow Java application via
WebStart. The program is regenerated once every two minutes. It is
simply a JFrame containing a JButton who's label is the current date
and time the application was generated. The link below shows the source
of the program and a script used to generate it once every two minutes.
(This example will be left up for a week or so, I'll stop the script
from running that regenerates it at that point, but leave the content
up)

http://www.linux4real.com/java/20060211/webstart/

For a pretty good tutorial, on how to use webstart.. go to the link
below. It also talks a bit about signing a jar to enable full
permissions. The above I gave above doesn't allow the application
delivered to have full access, it is meant to demonstrate webstart in
general. Signing jars is not a complicated process and will allow a
program to be deployed and auto-installed via the web *and* have as
much access as required (if the user permits it).

http://www.cokeandcode.com/info/webstart-howto.html
Back to top
Roedy Green
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: Why my java code is THAT slow compared too C++? Reply with quote

On Sat, 11 Feb 2006 20:27:26 +0000, Thomas Hawtin
<usenet (AT) tackline (DOT) plus.com> wrote, quoted or indirectly quoted someone
who said :

Quote:
Looking at the hash algorithm, it doesn't look conventional. Effectively
what you have is:

Sum s[i] * ((2^5 - 1) ^ i+1)

see some fast hashCode algorithms at
http://mindprod.com/jgloss/hashcode.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Back to top
Roedy Green
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: what are the other ways to prevent a class from being su Reply with quote

On Sun, 12 Feb 2006 04:38:22 GMT, EJP
<esmond.not.pitt (AT) not (DOT) bigpond.com> wrote, quoted or indirectly quoted
someone who said :

Quote:
I disagree. He has wasted his time by not doing his homework. This
applies to many situations, not just this one.

It is a trap for the unwary. There is no benefit in it. It is
motivated by malicious pranksterism. So I put the blame on the person
who set the trap, not the one who fell into in. Maintainable code
should not have traps.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Back to top
Roedy Green
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: what are the other ways to prevent a class from being su Reply with quote

On Sun, 12 Feb 2006 04:38:22 GMT, EJP
<esmond.not.pitt (AT) not (DOT) bigpond.com> wrote, quoted or indirectly quoted
someone who said :

Quote:

I agree, but this applies to *any* class, whether a mis-import or an
alternate implementation, which doesn't entirely meet the binary
contract of the expected class.

but it won't likely happen because if the class names differ because
you explicitly mention the class name in your code. The confusion
comes with generic wildcards that can give you an alternative class
you did not even know about.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Back to top
EJP
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: what are the other ways to prevent a class from being su Reply with quote

Roedy Green wrote:
Quote:
On Thu, 09 Feb 2006 08:36:19 GMT, EJP
I am confused since we have been discussing vaguely related issues in
different threads.

Not me.

Quote:
1. if you use wildcard imports you can get he wrong class and not
notice even at run time. All that has to happen is the signatures to
match of the methods you actually use.

I agree, but this applies to *any* class, whether a mis-import or an
alternate implementation, which doesn't entirely meet the binary
contract of the expected class.

Quote:
2. if someone makes all constructors private but leaves the class
itself public, someone researching his problem will note the class is
not final and base a design on that. when he actually comes to do the
work of extending the class he finds out when he compiles he is in
trouble since the super constructor is private. He has wasted time
designing and writing his class. That is tantalising. Shoot the
asshole who pulled this childish stunt.

I disagree. He has wasted his time by not doing his homework. This
applies to many situations, not just this one.

In *the situation under discussion*, there may be legitimate reasons for
making it non-final but with private constructors. The abstract factory
pattern is an example: the concrete subclass can be provided as a static
inner class. This seems like a useful feature to me and I may even have
used it some time.

Your language is not justified.
Back to top
ossie.moore@gmail.com
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: How to deploy Java Applications To People W/O Having To Reply with quote

Web Start is an excellent method of deployment. It provides a way to
auto update, inclusion of a start menu icon (and equivalent on
OSX/Linux) and even provides an "Add/Remove Program" entry on windows.
Back to top
ossie.moore@gmail.com
Guest





PostPosted: Sun Feb 12, 2006 5:35 am    Post subject: Re: Windows or Linux? Reply with quote

Note: you can refer to
"D:\MisArchivos\workspace\fingerprinting\config\words.txt" as
"D:/MisArchivos/workspace/fingerprinting/config/words.txt". ie.. File
file = new
File("D:/MisArchivos/workspace/fingerprinting/config/words.txt"); will
work. That said, I agree with the statement that using
File.pathSeparator (or it's peer, File.pathSeparatorChar) are more
reliable when building a path.

Note also, the reason
"D:\MisArchivos\workspace\fingerprinting\config\words.txt" becomes
"D:MisArchivosworkspace-ingerprintingconfigwords.txt" is because the
'\' char is an escape char in a quoted string. If you persist in using
the '\' char when building a file path, you need to escape it as
follows...
"D:\\MisArchivos\\workspace\\fingerprinting\\config\\words.txt"
Back to top
Roedy Green
Guest





PostPosted: Sun Feb 12, 2006 6:35 am    Post subject: Re: How to deploy Java Applications To People W/O Having To Reply with quote

On 11 Feb 2006 21:18:50 -0800, "ossie.moore (AT) gmail (DOT) com"
<ossie.moore (AT) gmail (DOT) com> wrote, quoted or indirectly quoted someone who
said :

Quote:
I'll stop the script
from running that regenerates it at that point, but leave the content
up)

I gather the process blows up during the jar build. You might want to
build the jar then in a fast move delete and rename. That can always
fail if the jar is being served.

I hope to find tools that deal with this problem with FTP, by
uploading, then swapping in the newly uploaded files to replace the
old ones only once the whole batch is up, and only when the old files
are not busy.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Back to top
Roedy Green
Guest





PostPosted: Sun Feb 12, 2006 6:35 am    Post subject: Re: How to deploy Java Applications To People W/O Having To Reply with quote

On 11 Feb 2006 21:23:32 -0800, "ossie.moore (AT) gmail (DOT) com"
<ossie.moore (AT) gmail (DOT) com> wrote, quoted or indirectly quoted someone who
said :

Quote:
But it
won't download unelss the webserver version has updates.

does the jnlp file have to change to trigger the update or just the
jar?
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Back to top
ossie.moore@gmail.com
Guest





PostPosted: Sun Feb 12, 2006 6:35 am    Post subject: Re: Tomcat on Linux Platform Reply with quote

Most likely, yoru Linux box is doing what any self-respecting OS should
do, protect its self from intruders. The reason you can't access it
from a remote machine is that your firewall is preventing remote users
from accessing your machine.

To fix this, just open TCP port 8080. The firewall gui till is
available from the menu, but i'm not on FC3 anymore, but you can launch
the gui program from the command line by running the...
redhat-config-securitylevel ...command.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming All times are GMT
Goto page Previous  1, 2, 3, ... 330, 331, 332  Next
Page 2 of 332

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.