C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 24th, 2002, 07:28 AM
Beans4You's Avatar
Beans4You Beans4You is offline
Some day I will be a Lambda!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: NJ
Posts: 18 Beans4You User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question FileTime???

Question:

I have a program that parses through a directory and gathers information. I'm now trying to trim the parse time down, it takes about 130 seconds to parse 10 gigs on a PIII 600 with 256 RAM. I can cut the time in almost half if I remove the file time functionality. I'm getting the Create, Last Viewed, and Last Modified times of each and every file on the system. Below I have included some code that I just ripped out of my program. I modified it a little just to make it look right. I have enclosed it so that I can show the logic that I'm using. If anyone has any idea of how I can accomplish this task a little more efficient I would be very grateful.

Code:
	TCHAR *szPath;		// The path of the folder / directory
	TCHAR szCurDirPath[400];
	TCHAR szTemp[5];
	TCHAR szDate[10];
	sprintf(szCurDirPath, "%s*.*", szPath);

	hFind = FindFirstFile(szCurDirPath, &data);

	data.ftCreationTime
	if ( FileTimeToSystemTime(&data.ftCreationTime, &stCreate) != 0 )
		ConvertFileTime(sCreateDate, stCreate);

	_itoa(stCreate.wMonth, szTemp, 10);
	sprintf(szDate, "%s-", szTemp);
	_itoa(stCreate.wDay, szTemp, 10);
	sprintf(szDate, "%s-", szTemp);
	_itoa(stCreate.wYear, szTemp, 10);
	sprintf(szDate, szTemp);

	printf("%s\n", szDate);


Thank you
Eric

Reply With Quote
  #2  
Old October 24th, 2002, 12:31 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,381 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 24 m 14 sec
Reputation Power: 4080
Why not just use sprintf() once and avoid using all the _itoa calls.
As a bonus, you can also get rid of szTemp, if you write your code something like this:
Code:
if ( FileTimeToSystemTime(&data.ftCreationTime, &stCreate) != 0 )
     sprintf(szDate, "%d-%d-%d", stCreate.wMonth, stCreate.wDay, stCreate.wYear);

printf("%s\n", szDate);


Hope this helps!

Reply With Quote
  #3  
Old October 24th, 2002, 05:03 PM
Beans4You's Avatar
Beans4You Beans4You is offline
Some day I will be a Lambda!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: NJ
Posts: 18 Beans4You User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
As always - You are the Man

I'll post back and let you know if this helps.

Thanks
Eric

Reply With Quote
  #4  
Old October 24th, 2002, 05:18 PM
Beans4You's Avatar
Beans4You Beans4You is offline
Some day I will be a Lambda!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: NJ
Posts: 18 Beans4You User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Scorpions4ever

That modification added 10 seconds on the scan time.
I'll reboot and see if it's becouse of other software running.

Eric

- - After the reboot the run time was almost the same as before the modification.

Last edited by Beans4You : October 24th, 2002 at 07:13 PM.

Reply With Quote
  #5  
Old November 7th, 2002, 06:37 PM
Beans4You's Avatar
Beans4You Beans4You is offline
Some day I will be a Lambda!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: NJ
Posts: 18 Beans4You User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Still doing research trying to figure this one out...

Now I have not used any real MFC programming and I'm a little scarred of it, but I found this function CTimeSpan which looks like it might be able to help me. This function can return the total number of days and hopefully remove allot of unnecessary conversions that I'm doing. I'm thinking something like: (FileTime_TotalDays - SystemTime_TotalDays) = number of days since {last view, modified, accessed}.

Can this be done? And if it can, does anyone know how to change filetime to CTimeSpan? Also, this program is just a normal C++ command line program, what changes will I need to implement to use an MFC function?

Eric

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > FileTime???

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap