473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Big Deal


I just whipped up this code in c# using Regular Expressions.

I found 1037 instances of "Relf" in cola in 15 milliseconds:

#region Using directives

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

#endregion

namespace ConsoleApplication1
{
public class FileClass
{
public static void Main()
{
String s = ReadFromFile("c:\\sample\\Cola.txt");

Regex rex = new Regex("Relf");

DateTime init = DateTime.Now;

int icount = rex.Matches(s).Count; // returns 1

DateTime end = DateTime.Now;

TimeSpan duration = end.Subtract(init);

Console.WriteLine("number of relfs " + icount);
Console.WriteLine(duration.Milliseconds);


}
static String ReadFromFile(string filename)
{
StreamReader SR;
String S;
SR = File.OpenText(filename);
S = SR.ReadToEnd();
SR.Close();
return S;
}
}
}

Jeff_Relf wrote:
Jeff_Relf ( 30, 10.28 P, A Individual.NET, X ),
Hi Kelsey, Oops my last attempt only searched ten thousand words,
This time I'm searching 100 thousand words.

I'm using Cola.TXT as my test file, which is about 4 megs,
and contains over 2,000 of the most recent articles.

My web page is down right now... too much traffic ?

But when it comes up, I hope to put a more recent Cola.TXT here:
( I say, hope, because I'm using NoCharge.COM, free dialup )
http://www.Cotse.NET/users/jeffrelf/Cola.TXT

Only spaces and below ( Ascii ) were considered whitespace.

Here were my latest results:
Searching the first one hundred thousand words in Cola.TXT.

.00167 Seconds to find 12 occurences of Relf .
.00089 Seconds to find 0 occurences of sesquipedalian .

My machine is very slow too, the L2 cache is only 128 KB,
with 256 MB of DRAM and a 40 gig hard disk.

When my web page comes up I'll put the .EXE and .CPP files here:
http://www.Cotse.NET/users/jeffrelf/Search.EXE
http://www.Cotse.NET/users/jeffrelf/Search.CPP

Not including my standard macros, but including the timing code,
this was my main(): <<
main() {
QueryPerformanceFrequency( ( Quad * ) & Secnd ); Secnd_Dub = Secnd ;
FILE * fp = fopen( "Cola.TXT", "r" );
if ( ! fp ) { printf("_ Word.TXT _ Can't be Read." ); return ; }
int Sz = filelength( fileno( fp ) ) + 1 ; LnT Ln = { 0 };
{ LnP B = ( LnP ) malloc( Sz ); Sz = fread( B, 1, Sz, fp );
fclose( fp ); fp = fopen( "Results.TXT", "w" );
B [ Sz ] = 0 ; LnP P = B ; int Ch = * P --, Ch2 ;
GoToDark
Loop( 100000 ) { Inc ( Ln ) = P ; if ( ! Ch ) break ; Next_Tok }
if ( J < LLL ) {
fprintf( fp, "Found %d thousand words, needed 100.", J / 1000 );
fclose( fp ); return ; } }
fprintf( fp
, "Searching the first one hundred thousand words in Cola.TXT.\n\n");
LnP Pats [] = { "Relf", "sesquipedalian" };
Loop( sizeof Pats / sizeof * Pats ) { LnP Pat = Pats [ J ];
double Mark = Secs ;
int Cnt = 0 ; LoopXx ( Ln ) if ( Eq( P, Pat ) ) Cnt ++ ;
double Dur = Secs - Mark ;
char SecStr [ 99 ] ; sprintf( SecStr, "%1.5f" , Dur );
fprintf( fp, "%s Seconds to find %d occurences of %s .\n"
, SecStr + ( * SecStr == '0' ), Cnt, Pat ); } fclose( fp ); } >>

Nov 17 '05 #1
0 885

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Alex Shi | last post by:
Any good idea or a reference link to deal with search engine for php web pages? Thanks in advance! Alex
9
by: _mario lat | last post by:
I'd like to deal (update, deal, insert....) a database (with tables and relationship between these) by a tool written in php. I need to share and work on a database with other people. I'd like to...
6
by: christian9997 | last post by:
Hi We have started off using a $_GET parameter to keep track of the user's browser: We detect what browser the visitor is using when he first arrives on our website then we do a redirect to...
1
by: Davy | last post by:
My program deal with a several level tree with several branchs. The amount of branchs from father node is not known. So I want to creat a tree with dynamic branchs. Now I use the structure:...
5
by: Amr | last post by:
Hi i need a library to deal with the modem, cause i have to make an application that connect to the modem and deal a number, and wirte the events (busy, answered, not answered)
7
by: rbt | last post by:
The house almost always wins or are my assumptions wrong... import random amounts = results = count = 0 while count < 10:
48
by: Frederick Gotham | last post by:
The "toupper" function takes an int as an argument. That's not too irrational given that a character literal is of type "int" in C. (Although why it isn't of type "char" escapes me... ) The...
7
by: rockdale | last post by:
Hi, How do you guys deal with the different clinet resolution? For example, you have 800*600, 1024*768 and 1280*1024 on client side. We used to put everything into a table with fixed width (the...
10
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Which newsgroups deal with javascript? ----------------------------------------------------------------------- ...
0
by: AWHF | last post by:
hey, is there anyone who know how to deal with vector? i have 2 files as below: file1.doc ::component list ::Start green in grp1 blue in grp2
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.