Log in

View Full Version : Count To 1,000,000,000 - Software by me



Trace
03-31-2008, 10:32 PM
I quickly programmed a piece of software to write a text file counting to 1,000,000,000 or 1 billion. Every line has the next sequential number.

It is currently counting the time it's taking in Milliseconds.

My next step is to ask Google if they would build a super computer (skulltrail) platform for me to run a piece of software to count to, you guessed it, a google. which is a number with 100 zeros after it.

It would be interesting how long it takes and how much hard drive space it takes up.

When I checked the text file on my computer, I was up to around 2.4 million and its already taking 35MB.
I'm estimating it will take about 17.5 GBs when it is done.

If you would like a copy of the software, let me know and I'll set you up with it to count to what ever number you want.

Post comments here. I'll let you all know how many milliseconds it takes to complete! Bye for now, I don't want to steal precious CPU time from the software!

-Trace

Omega
03-31-2008, 10:47 PM
Program it to count to a google. I want to kill a laptop. =D

Trace
03-31-2008, 11:01 PM
K, I'll get right on it!
Haha, I maxed out the maximum number of pages allowed in MS Word
What time would you like it to record it? Minutes, hours, days, years? Centuries? haha

Omega
03-31-2008, 11:05 PM
months or years sounds good to me


hell, I might just run it on my server and see how long I can keep it going, lol

Trace
03-31-2008, 11:09 PM
It will take plenty of time. I'm thinking its going to take me a week or two just to reach 1 billion.

I'll make it print out every hour what number its on.

Omega
03-31-2008, 11:13 PM
It will take plenty of time. I'm thinking its going to take me a week or two just to reach 1 billion.

I'll make it print out every hour what number its on.

alright


and oh man this is going to be crazy

Trace
03-31-2008, 11:20 PM
Should work, you can find it here: http://rapidshare.com/files/103949275/Count2Google.zip.html

Report any errors and I'll fix them!

Doesn't look like it can handle that much data. Let me make a work around. h/o

xRyokenx
03-31-2008, 11:26 PM
This seems interesting... I'll keep my eye on it.

Trace
03-31-2008, 11:35 PM
Ok, here is a version that will run to 10 billion: http://rapidshare.com/files/103950933/Count2Google.zip.html
Report any errors, looks like it will work.
It should report every hour what number it is on

Thanks for the eye. I'm going to write a letter to Google I think

xRyokenx
03-31-2008, 11:39 PM
You're welcome and I forgot the eye.

*insert eye here*

Trace
03-31-2008, 11:41 PM
hahaha +REP for the laugh.

Quakken
03-31-2008, 11:43 PM
This is very interesting. It ends up storing it in the hard drive live, while it is doing it?

It would probably fill the ram with digits very quickly, but I have absolutely 0 idea what I am talking about. How long does it take to get to 10 billion?

Trace
03-31-2008, 11:46 PM
Yea, If you want the source, I'll be happy to post it.

Considering it's still running to 1 Billion and isn't anywhere near, I'm thinking 1 week for a billion and exponentially greater from there. Maybe a year? Depends on the computer

crenn
03-31-2008, 11:46 PM
You're going to run into problems when you get upto 10000000000000000000000000000000000000.

10^37

Trace
03-31-2008, 11:49 PM
really? Why is that? Is there a way to work around it maybe?

crenn
03-31-2008, 11:51 PM
Limitations of programming languages. Well that I know of currently.

Trace
03-31-2008, 11:54 PM
And considering it's only VB6 which is horrible, I'm sure it will.

I'll see what I can do. But 10 Billion isn't bad

And, I'm going to start on a TBCS Screensaver that uses the RSS feed to update it.

Quakken
03-31-2008, 11:58 PM
Should've used emacs. or butterflies.

http://xkcd.com/378/

Trace
04-01-2008, 12:00 AM
Haha +Rep for another laugh.

I've never heard of Emacs

xRyokenx
04-01-2008, 12:00 AM
Emacs freaking suck. They look funny too.

I might run this while I go to work... see how long it takes.

crenn
04-01-2008, 12:02 AM
Your best bet is to use unsigned values. I can write a C program that will hit the limit very quickly (depending on the system it's run on). I can use upto a 64-bit (binary) number. I can proberly work out how many bits it would be needed if given a few hours. It will take a bit of processing power and a lot of dividing by 2.

Trace
04-01-2008, 12:02 AM
Oh, it'll take a long time
to crenn- I basically write the value to the hard drive almost like streaming, so the only value stored in the variable is the current number so 1 2 3 4 5 6 7 etc.
i think it will throw an error when it reaches 1 billion...

crenn
04-01-2008, 12:09 AM
What does the output look like? Does it print it to a new line?

Trace
04-01-2008, 12:11 AM
yea, every line should have a new number on it. But I seem to be getting random quote marks in it, so i may have to write a program to clear those out. then it would be a good password cracker library haha.

crenn
04-01-2008, 12:13 AM
I'll write a program while on my way home to do this and get it to run on a core of my desktop ;).

3.15GHz will help pound out those numbers, but I'll hit a limit at one point.

EDIT: btw, the sum of all those numbers will be:
50000000005000000000

Trace
04-01-2008, 12:15 AM
Yea, what language do you program?
I have it running on a single core too! haha

EDIT: How did you figure that 1 out? I know there is a formula but I forget it

The sublimation or something?

crenn
04-01-2008, 12:18 AM
I currently program in C, but I'll be moving to C++ later this semester.

Trace
04-01-2008, 12:21 AM
College class?
I was supposed to be taking AP Computer Science which is basically Java programing but only 15 kids signed up so I guess they aren't offering it...

Btw: Freshman in highschool here haha

crenn
04-01-2008, 12:30 AM
I'm currently at university studying a Bach. of Engineer (Robotics and Mechatronics).
It's part of my standard course.... it's essentially a requirement.

btw, You're looking at around 103GB if you have 11 numbers per line.

Trace
04-01-2008, 12:33 AM
Oh wow, really that much?!?!

crenn
04-01-2008, 12:34 AM
Actually I forgot to include the new line. It's actually 121.1GB approx.

EDIT: For those wondering how I calculated this number. Make a new blank TXT file and put in the maximum, in this case


10000000000

Then press enter so it goes into a new line. Then check how large the file is. In my case, it was 13 bytes. So there will be 10000000000 lines if we start from 1. So times 13 by the number of lines and you have the amount of bytes it would take. Then divide by 1024 to get kB, then again to get MB, and again to get GB.

Trace
04-01-2008, 12:35 AM
How did you figure that one out?
(I love having smart people to talk to. so much better then at my highschool)

EDIT: I found it interesting that setting a program to just do the following code, it only took 23 seconds:


for i=1 to 1000000000
i=i+1
next i

crenn
04-01-2008, 12:42 AM
#include<stdio.h>
#define MAX 10000000000

int main(void)
{
int i=0;
while(i<MAX)
i++;
printf("Done");
}

EDIT: See above edit.

Trace
04-01-2008, 12:44 AM
That doesn't keep track of how long it took to do it. I was curious because writing it to file adds a huge amount of time. 23 seconds to count to it yet, it is still running the one that writes to file

crenn
04-01-2008, 12:46 AM
Oh you want to get it to print the time in seconds? I'll do that later, I should be finishing off a lab report right now ^-^;

Trace
04-01-2008, 12:49 AM
H/o could you try this program for me?

http://rapidshare.com/files/103959603/Test.exe.html

crenn
04-01-2008, 07:04 AM
Took 641ms to complete.

EDIT: I just wrote a C program to count upto 10000000000 (No easy task) and it's about 24 seconds. But the program you sent me took less than a second..... hmmm....

Trace
04-01-2008, 07:43 PM
you exponentially increase with every zero.

I just redid the code(in english class when it got boring), should take 10 minutes tops, i'm trying it now

EDIT: Well, in 5 minutes I was above 3 million. Which is better. IT IS STILL NOT GOOD ENOUGH
I am going to go through and optimize the code as much as possible.

Maybe 50 Hours? Until I optimize...

.Maleficus.
04-01-2008, 09:03 PM
Emacs freaking suck. They look funny too.

I might run this while I go to work... see how long it takes.
LOL.

http://www.kenrockwell.com/apple/images/05emac_3q.jpg

<>

Emacs (http://www.gnu.org/software/emacs/)

Yes, I just wrote a sentence in pseudo code. And as far as XKCD goes, I have to agree that real programmers use Vi. Or a magnetized needle.

Does this program create a .doc file? If it does, you can save a considerable amount of space with a .txt file... However I skipped most of the thread, so please feel free to ridicule me if that was a dumb question.

Trace
04-01-2008, 09:36 PM
No, a .txt file
I was able to Rar the text files (1000 text files containing a series of 10000 numbers each) into a 3.27 mb file which is down from 88MB
Took me about 15 minutes to generate 10million digits. I'll be optimizing code all night to lower my times. if anybody wants my current code, or program let me know

crenn
04-02-2008, 07:44 AM
I think I can beat that time!

I just need to write a function to put the numbers into a file.

Trace
04-02-2008, 08:16 PM
I'm sure C is faster. Especially since you learned in a class haha. I taught myself.
I'm working on a program to figure out the best amount of numbers to put into each file for the best speed.

silverdemon
04-03-2008, 05:30 AM
I tried to make a program like yours yesterday in Visual Basic. It worked, counted to whatever number you entered and displayed the time taken and also during the counting the current number it is at (gets larger very fast :D).

But at around 400.000 the graphical interface of the program glitches and you can no longer see anything on the interface (no buttons, textboxes etc.) The program does however still counts and displays the time taken once its finished.
I can do something about it: put a 'DoEvents' in there somewhere, but than the counting takes up to 25% longer.

now, I don't really mind that my program is not working a 100%, but did you have the same issues? or don't you use a GUI anyway?

XcOM
04-03-2008, 05:02 PM
im interested in this, PM me, i would like to see the source code, i am correct in thinking you have coded it in VB6?

weazel6265
04-03-2008, 06:16 PM
I just wrote a program (Java) that counts to 1,000,000,000 and stores all the numbers into a txt file, it runs in about 10 minutes, with a resulting file of 9.2Gb.

I'm not sure if I'm misunderstanding what you guys are doing, or what is taking so long, and where you are getting your enormous sizes from.


Heres my code:

import java.util.*;
import java.io.*;
import java.util.Date;
import java.lang.management.ThreadMXBean;
import java.lang.management.ManagementFactory;
public class TCBS{
public static void main(String args[]){
ThreadMXBean tb = ManagementFactory.getThreadMXBean();
long starttime = tb.getCurrentThreadCpuTime();
try{
BufferedWriter file=new BufferedWriter(new FileWriter(new File("TCBS.txt")));

int i=0;
for (i=0; i<1000000000; i++)
file.write(i+"\n");
System.out.println(i);
file.flush();
file.close();
} catch(Exception e){e.printStackTrace();}

long stoptime = tb.getCurrentThreadCpuTime();
long timeused = (stoptime - starttime) / 1000000;
System.out.println(timeused+" milliseconds");
}
}

crenn
04-03-2008, 06:25 PM
My enormous file size comes from the fact that 1 would appear as:


00000000001
Compared to just

1

Trace
04-03-2008, 06:52 PM
Ok, You are correct, it is in VB6

silverdemon, I would like to see your code. When I set mine counting, and it is supposed to be listing which number it is on, it freezes from the beginning. I even tried adding a DoEvents but then it didn't count at all.

What is taking so long, is that it is in VB6 for one. File I/O takes a lot of time so I don't think writing it every time is as good as storing in a variable.

I'm reworking the code (again) to increase speed. I'll make a note of my time when I finish.

@ XcOM, consider the PM sent.

silverdemon
04-04-2008, 03:08 AM
Ok, here is the snippet of code i produced. I am indeed using VB6.0

just a reminder: I haven't done a lot of work on this, it does NOT write to a file (yet) and it counts in seconds (not milliseconds). Don't flame me for this 5 minute job please :D


Dim Finish As Long
Dim StartTime As Date
Dim TimeTaken As Date

Private Sub cmdStart_Click()
Finish = Val(txtNumber.Text)
StartTime = Time

For i = 0 To Finish
'write number to box
picCurNum.Cls
picCurNum.Print i
'write time to box
TimeTaken = Time - StartTime
lblTime.Caption = TimeTaken
DoEvents 'This is the DoEvents I was talking about
Next i

message = MsgBox("Done counting from 0 to " & Finish & ". Time taken: " & TimeTaken, vbOKOnly, "Done!")

End Sub

XcOM & Trace: I sent you a PM with linky to files

p0Pe
04-04-2008, 04:11 AM
why dont you use your time on coding a robot that collects data about the surrounding environment, then discards it and drives into walls? that would be funnier xD

silverdemon
04-04-2008, 04:16 AM
If you can show me a way of building an actual robot that I can program for a very tiny amount of money, I would...

crenn
04-04-2008, 04:56 AM
Lego.

EDIT: For those who want the C code for my counting program:

http://au.geocities.com/crenn6977/Count.zip

XcOM
04-04-2008, 04:01 PM
ok, checkout the challange forum, i am going to start a comp with this.

Trace
04-04-2008, 07:37 PM
Ok, I entered the contest.

crenn
04-08-2008, 12:57 AM
btw, it will take between a 256-384bit number for a number as large as google.