Solved

Java/C: Code running longer and longer

Posted on 2008-06-16
6
176 Views
Last Modified: 2013-11-23
Hi experts,

I am puzzled with this so I post to get explainations. I have Java and C code on Linux machine. I found that the Java code cost more and more time. It is the same for the C code. I wrote this C code about one month ago and did not touch it since then. Today I run it and found the running time got doubled. I used clock() to measure time.

How can this code run with longer time? or why do they become slow?

Thanks for any replies.
0
Comment
Question by:davidw88
6 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 50 total points
ID: 21797713
Can you tell us anything about the code?
Does the code read any data?
Does the code do different things depending on the date?
Was the machine doing anything else while the code was running?
Can you show us the code in question?
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 21798323
Could be other processes taking up more resources on your box

0
 
LVL 11

Assisted Solution

by:spoxox
spoxox earned 100 total points
ID: 21798491
Java and C are deterministic languages. If the same thing goes in, the same stuff comes out. Barring any element of randomness, the same CPU effort is required. Clock does not measure how much CPU your program is using. It tells you how much time has elapsed.

The program's running time can be influenced by:

1) data input/output. If the program reads a file, changes in the file will affect the running time.

2) environmental changes. If system RAM increases or decreases; if the CPU or instruction pathways have changed; if available RAM increases or decreases (owing to the execution of other processes); if the i/o system is changed; if any hardware is failing, the running time will change. O/S changes (operating system processes) can also affect the running time.

Most influencing factors should fall under one of these two broad categories.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 9

Expert Comment

by:mbodewes
ID: 21798719
In all my performance problems so far with Java and even C, the best bet is to disable the virusscanner. A scanner trying to read every .jar in it's entirety (McAfee) and deleting it if it finds any problems doesn't do much good for developers piece of mind. Stopping your firewall to block connections to/from your own machine may also help.

I cannot see from here if this would fix your problems, try the other possible solutions as well. But at least this solution is one that might work (given the absolute minimum of data you've supplied to us).
0
 
LVL 10
ID: 21799624
Check whether any other processes are running other than java and c. May be because of that reason these programs are taking moretime.
0
 

Author Comment

by:davidw88
ID: 21805089
Hi experts,

Thanks so much for all your replies. I called our administrator to check with me together about the processes. We found that another file writing process took so much resources that it slowed my code!!

Objects, Spoxox and Ozo are correct so I split the points among them.

Thanks also go to mbodewes and melchkishore! (melchkishore's answer follows Objects' so I do not assign points to him.)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now