VB or Java 
Author Message
 VB or Java

I am trying to create a dll which represents a document.
In this I have a table object, which represents a regular
table. To this table I keep on adding Cell objects, which
can go upto 2000 depending upon the size of the table.
Since I cannot write the table until I have all the cells
added to the table object, it is taking lot of CPU. I have
similar code in Java... but it won't take that much of
CPU. (When I see in the Task Manager, with VB, I get the
CPU usage 100%, where as in Java it won't be more than
90%) Is that means Java is more efficient in handling
memory or my code is bad? Can somebody enlighten me....

thanx



Wed, 14 Jul 2004 05:46:56 GMT  
 VB or Java
what tastes better - apples or pears?

--

Enterprise Development: http://www.dev-purgatory.org/


Quote:
> I am trying to create a dll which represents a document.
> In this I have a table object, which represents a regular
> table. To this table I keep on adding Cell objects, which
> can go upto 2000 depending upon the size of the table.
> Since I cannot write the table until I have all the cells
> added to the table object, it is taking lot of CPU. I have
> similar code in Java... but it won't take that much of
> CPU. (When I see in the Task Manager, with VB, I get the
> CPU usage 100%, where as in Java it won't be more than
> 90%) Is that means Java is more efficient in handling
> memory or my code is bad? Can somebody enlighten me....

> thanx



Wed, 14 Jul 2004 06:31:10 GMT  
 VB or Java

Quote:

> I am trying to create a dll which represents a document.
> In this I have a table object, which represents a regular
> table. To this table I keep on adding Cell objects, which
> can go upto 2000 depending upon the size of the table.
> Since I cannot write the table until I have all the cells
> added to the table object, it is taking lot of CPU. I have
> similar code in Java... but it won't take that much of
> CPU. (When I see in the Task Manager, with VB, I get the
> CPU usage 100%, where as in Java it won't be more than
> 90%) Is that means Java is more efficient in handling
> memory or my code is bad? Can somebody enlighten me....

What is this "table" object?  If it contains a dynamic array, are
you growing it with Redim Preserve each and every time you add a
cell?  That's probably what is killing you.  Here's an (air-code)
example of growing an array by 50% or 100% as needed, which should
be much faster:

dim lines() as string, linecount as long
redim lines(0 to 3)

dim fd as integer: fd = freefile
open "myfile.txt" for input access read as #fd len = 4096

do until eof(fd)
  if linecount > ubound(lines) then
    ' redim preserve lines(0 to linecount * 2) ' double the array size
    redim preserve lines(0 to linecount + linecount \ 2) ' grow by 50%
  end if
  line input #fd, lines(linecount)
  linecount = linecount + 1
loop

close #fd

' trim any excess elements from the array
if linecount = 0 then
  erase lines
elseif linecount <= ubound(lines) then
  redim preserve lines(0 to linecount - 1)
end if

--
Joe Foster <mailto:jlfoster%40znet.com>  Sign the Check! <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Wed, 14 Jul 2004 06:28:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB vs JAVA

2. ? how do you share a variable between vb and java scripting

3. IL-CHI//OBJECT ORIENTED DEVELOPERS...SMALLTALK,C++,VB,JAVA

4. IL-CHI//OBJECT ORIENTED DEVELOPERS...SMALLTALK,C++,VB,JAVA

5. Book on programming: VB to Java

6. VB versus Java

7. Converting VB to Java

8. looking for VB to Java books!

9. A VB-To-Java Grace Program Manifesto

10. Power of VB over Java, C++

11. Medical Speech Recognition (VB/C++/Java)

12. Interaction between VB and Java

 

 
Powered by phpBB® Forum Software