Solved

Java/C: Code running longer and longer

Posted on 2008-06-16
6
178 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

831 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