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, 4 ... 328, 329, 330  Next
 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming
View previous topic :: View next topic  
Author Message
ossie.moore@gmail.com
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



just the jar. Infact, you'll note that my example only updates the jar,
not the jnlp file (see recompile.sh content in the index.html page)
Back to top
ossie.moore@gmail.com
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



I'm doing exactly what you state. I mentiont that i'll stop it runnign
simply because i don't want to leave a script compiling a source file
once every two minutes forever.
Back to top
ossie.moore@gmail.com
Guest





PostPosted: Sun Feb 12, 2006 6:35 am    Post subject: Re: log4j two levels at once Reply with quote



You can do that and so much more. Example.. for both the default logger
and for any particular class, you can setup multiple loggers, at
different levels.

Example...

Say you have a program doing something odd and you want to debug a
particular class. You could set the default logger to "INFO" for
Console, "WARN" for file. Then, add an entry for the suspect class to
log at "DEBUG" for Console. This way, you'd see DEBUG messages on the
console for that particular class. Heck, you could even send DEBUG
level logging for a particular class to say syslog while having another
class send DEBUG to another file. You can also vary the format of the
log messages from appender to appender.
Back to top
Luc The Perverse
Guest





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

"Chris Smith" <cdsmith (AT) twu (DOT) net> wrote in message
news:MPG.1e572699ccd42c92989d9d (AT) news (DOT) altopia.net...
Quote:
Luc The Perverse <sll_noSpamlicious_z_XXX_m (AT) cc (DOT) usu.edu> wrote:
It is clear that you are new to programming. Try not using a path at
all,
and see where files go. You should be able to use this "working
directory"
to keep your files in.

Sorry, Luc, but I think that's really bad advice. In a GUI environment,
the current working directory is almost always an unclear concept to the
user, and it's not defined by any relevant specification. Applications
should not make use of the current working directory unless it's clearly
the intent of the user for it to do so, which implies that it's probably
a command line utility. Command line utilities are among the rarest
uses of Java applications, and in the few cases where they are written,
the author already knows, as a fact, that the CWD is required.


He;s tring to learn very basic programming concepts - my suggestion was to
get everything else working before worrying about platform independant
pathing. He is obviously on a windows box right now using a hard coded path


--
LTP

:)
Back to top
Luc The Perverse
Guest





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

"Thomas Hawtin" <usenet (AT) tackline (DOT) plus.com> wrote in message
news:43ee4358$0$9225$ed2619ec@ptn-nntp-reader01.plus.net...
Quote:
That is not necessarily why the C code is faster.


My initial gut reaction, and his solution both seem to hint at the idea that
he was using an inefficient algorithm.

I have coded a word frequency calculator in C++ before, and used N^2
efficiency sorting algorithms and they were VERY slow.

So I disagree - he changed one thing and now they run in about the same
amount of time as opposed to the java running more than double. To me that
seems pretty conclusive.

--
LTP

:)
Back to top
ossie.moore@gmail.com
Guest





PostPosted: Sun Feb 12, 2006 6:35 am    Post subject: Re: max heap size on 32 bit linux ? Reply with quote

This has to do with the max memory a particular process can occupy. I
believe the *default* value most vendors us in workstation editions of
Linux is 2GB of ram per process (minus some overhead). You can
reconfigure your kernel manually to allow more memory, or, if you are
not comfortable doing that, purchase an enterprise edition support
package.

Here's an old post i found by googling for "linux max memory per
process"...
http://lists.samba.org/archive/linux/2005-November/014552.html
Back to top
priyom
Guest





PostPosted: Sun Feb 12, 2006 9:12 am    Post subject: Re: javamail send error Reply with quote

"The fact that your address is valid is not sufficient, since a
correctly configured mail server will only accept mail to or from its
own mail domain."
-What I meant was it's not an address problem. I am in the same domain,
connecting through LAN and trying to send a mail to myself, which I
presume would be in the same domain (I do have an ID created in the
domain with send capability)
Back to top
Jon Martin Solaas
Guest





PostPosted: Sun Feb 12, 2006 10:12 am    Post subject: Re: cpu intesive jave program Reply with quote

puzzlecracker wrote:
Quote:
Basically, you need some way of hooking into the scheduler, or know exactly
what the other processes on the system are doing.


do i really need know what other processes are doing? Let's say I am
not concerned with current percentage, but only with a value I want it
to boost to.

ex. currently cpu%=50
I want to to raise it by 20%, and that is fine if some other processes
raise it by some value n during interupts....

All I care is to know that my call can raise it if there is a room.
That is all.


What exactly are you after? Boosting the jvm process scheduler priority?
You can use System.execute to run the renice command, but this won't
set a fixed cpu utilization, if the process is given low priority it'll
still consume 100% cpu if there aren't other processes in need of
cpu-cycles. Likewise, your process may be slowed down if it's
io-intensive, and won't be able to consume all cpu-cycles available.

Maybe you should look into a platform with realtime features, like
RT-Linux. And if you describe exactly what you need to do I'm sure
someone will be able to come up with much better answers than this :-)

--
jon martin solaas
Back to top
Gordon Beaton
Guest





PostPosted: Sun Feb 12, 2006 10:12 am    Post subject: Re: Null Webserver Reply with quote

On Sun, 12 Feb 2006 02:09:25 -0700, Luc The Perverse wrote:
Quote:
You see though, that's the thing - I don't know where to look for the
simplest protocal instructions. I search for HTML specification and find a
W3C subsite that is at least hundreds of pages long - and it still doesn't
answer the most basic questions.

Then I realize HTML specification isn't what I'm looking for, so I
search for web server specifications and get nothing related to what
I need.

HTTP is described in rfc2616. Some extensions are described in other
documents but rfc2616 is all you need to write a basic web server.

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Back to top
Luc The Perverse
Guest





PostPosted: Sun Feb 12, 2006 10:12 am    Post subject: Re: Null Webserver Reply with quote

"Chris Uppal" <chris.uppal (AT) metagnostic (DOT) REMOVE-THIS.org> wrote in message
news:43ee01d5$1$1171$bed64819 (AT) news (DOT) gradwell.net...
Quote:
Anyway, it would be a reasonable starting point if you prefer to work by
reading and modifying existing code. If not, then creating a simple HTTP
server from scratch would be an interesting and informative exercise, one
I
suspect you would enjoy -- the Sun code gives you an idea of the scale of
the
problem Wink

You see though, that's the thing - I don't know where to look for the
simplest protocal instructions. I search for HTML specification and find a
W3C subsite that is at least hundreds of pages long - and it still doesn't
answer the most basic questions.

Then I realize HTML specification isn't what I'm looking for, so I search
for web server specifications and get nothing related to what I need. I
assume it's a TCP connection, but I'm not positive.

I could mindlessly hack away at the example code, but I don't think that
would do much.

Or I could start at the other end and use a packet sniffer and try to
determine what it is doing. This would be a good learning experience, but
I'm not sure I'm that bored.

What I'd like is a build your own webserver tutorial - or at least an
incremental approach to understanding webserver communications. If that
doesn't exist, where can I find a mature full specification of the
communication?

--
LTP

:)
Back to top
Gordon Beaton
Guest





PostPosted: Sun Feb 12, 2006 11:12 am    Post subject: Re: Null Webserver Reply with quote

On Fri, 10 Feb 2006 16:27:49 -0700, Luc The Perverse wrote:
Quote:
To reduce ads that I see, I have downloaded a 1/2 mb hosts file
which routes most DNS to localhost 127.0.0.1

Problem is, sometimes it displays "cannot find page" and it tries
and waits for a picture to load.

I'd like to fill the void, with a webserver that serves nothing but blank
pages, and null media. (1x1 transparent gif, 1x1 JPG, Empty do nothing
Flash etc.)

I've done something similar to generate random pages. All that's
necessary is that you read (and ignore) the request, then respond with
whatever content you like.

Run it from inetd or similar and you don't even need to deal with the
socket connections, you can read from System.in and write to
System.out. It really doesn't need to be more complicated than this
(this code is untested):

// get request
br = new BufferedReader(...(System.in));
while (((line = br.readLine()) != null) && (line.length != 0));

// response header
System.out.println("HTTP/1.1 200 OK");
System.out.println("Date: %s" + rfcDate());
System.out.println("Server: Apache/2.0.50 (Unix) DAV/2");
System.out.println("Connection: close");
System.out.println("Content-Type: text/html; charset=iso-8859-1");
System.out.println();

// response body
System.out.println("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">");

// add your null content here
System.out.println(getNullContent());

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Back to top
Gordon Beaton
Guest





PostPosted: Sun Feb 12, 2006 11:12 am    Post subject: Re: Null Webserver Reply with quote

On 12 Feb 2006 11:30:31 +0100, Gordon Beaton wrote:
Quote:
System.out.println("Date: %s" + rfcDate());

My C is showing. Should have been:

System.out.println("Date: " + rfcDate());

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Back to top
Thomas Hawtin
Guest





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

Luc The Perverse wrote:
Quote:
"Thomas Hawtin" <usenet (AT) tackline (DOT) plus.com> wrote in message
news:43ee4358$0$9225$ed2619ec@ptn-nntp-reader01.plus.net...
That is not necessarily why the C code is faster.


My initial gut reaction, and his solution both seem to hint at the idea that
he was using an inefficient algorithm.

It is vastly more important that the hash code produce a good answer
than that it be ultra quick.

With two multiplies, the hash code computation wasn't as cheap as it
might have been. Sun's JVM seems poor at replacing constant multiplies
with shifts and adds/subtracts, although that is less important with
faster multipliers. If you replace v = v*31; with v = (v<<5) - v; and
perhaps look at two together (v = (v<<10) - 2*(v<<5) + vWink you might
understand that the low order bits are not going to be fairly distributed.

Quote:
I have coded a word frequency calculator in C++ before, and used N^2
efficiency sorting algorithms and they were VERY slow.

Doing n operation on a hash map take O(n) time, apparently. Screw your
hash code up, and it becomes O(n^2) and your caches burn for an extra
constant time slow down.

Quote:
So I disagree - he changed one thing and now they run in about the same
amount of time as opposed to the java running more than double. To me that
seems pretty conclusive.

How the hash code was calculation was performed changed (almost
certainly to a slower technique). Checking the implementation of
HashMap, it will only calculate the hash map once when inserting (or
retrieving) an entry. There is no way that the time taken to calculate
the hash code is going to make any impact on performance.

The original poster didn't know about the embedded hash code at the time
of writing the original code. It seems unlikely that the file format
happened to get the same hash value. So that was a separate change.
Given the likelihood of collisions with the first algorithm, that is a
very good candidate for causing the increased performance.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
Back to top
Chris Uppal
Guest





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

Thomas Hawtin wrote:

Quote:
The original poster didn't know about the embedded hash code at the time
of writing the original code. It seems unlikely that the file format
happened to get the same hash value. So that was a separate change.
Given the likelihood of collisions with the first algorithm, that is a
very good candidate for causing the increased performance.

There's also the marginal effect that the OP was probably interpreting the hash
code strings as words and adding them to the table too. Not only would that
double the number of words in the table, the words themselves would have a much
reduced distribution (all decimal digits, or some such) which might further
exacerbate any problem caused by weak hashing.

-- chris
Back to top
JavaEnquirer
Guest





PostPosted: Sun Feb 12, 2006 12:12 pm    Post subject: Re: Generics and getClass Reply with quote

Quote:
The solution I've most commonly seen is to pass in an instance of
Class<T>.

E.g.

String foo = makeMeThisObject(String.class);

- Oliver

Cheers Oliver, I feared that I'd have to do that, though, fear is too
strong a word!!!
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, 4 ... 328, 329, 330  Next
Page 3 of 330

 
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.