Results 1 to 5 of 5

Thread: VisualBasic - Copy cache?

  1. #1
    LWA
    LWA is offline
    Senior Member
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,171
    Thanks
    134
    Thanked
    57 times in 41 posts

    Question VisualBasic - Copy cache?

    Hey all,
    We are using the following script to performance monitor some SharePoint servers:

    Code:
    Option Explicit
    Dim oFSO, oWN
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oWN = CreateObject("WScript.Network")
    
    '// This makes sure the drive is not there
    If Not oFSO.DriveExists("Z:") Then
    '// Map the drive
    oWN.MapNetworkDrive "Z:", "\\servername\GAS\uk\it_pub"
    Else
    
    End If
    
    Dim olddate, nowdate
    
    olddate = Now
    '// Copying the file to the folder this script is stored in
    oFSO.CopyFile "z:\downloadtest\test2.pdf", Replace(WScript.ScriptFullName,WScript.ScriptName,""), true
    nowdate = Now
    Msgbox "Time taken to copy the 10MB file was " & DateDiff("s", olddate, nowdate) & " seconds"
    
    oFSO.deleteFile Replace(WScript.ScriptFullName,WScript.ScriptName,"") & "\test2.pdf"
    
    '// Clean up
    oWN.RemoveNetworkDrive "Z:"
    Set oWN = Nothing
    Set oFSO = Nothing 
    Set olddate = Nothing
    Set nowdate = Nothing
    The first run of this code returns around 300seconds (which is what I'd expect) but the second run completes in about 6 seconds! Now I assume it is caching somewhere but does anyone know how to turn this off?

    Thanks,
    Leon

  2. #2
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,231
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: VisualBasic - Copy cache?

    You expect it to take 5 minutes to copy a 10MB file across a network? Exactly what kind of network are you testing this on?

  3. #3
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts

    Re: VisualBasic - Copy cache?

    Is it SCS?
    To err is human. To really foul things up ... you need a computer.

  4. #4
    TLO
    TLO is offline
    Registered+
    Join Date
    Oct 2009
    Posts
    23
    Thanks
    0
    Thanked
    0 times in 0 posts

    Re: VisualBasic - Copy cache?

    Problem is that the FileSystemObject is going to be using Window's file copy mechanism and therefore caching is going to be used.

    One method would be to vary the source file used - not sure if renaming or copying the file would be enough to trip up the caching - or to use an alternate method of copying the file. You can always read the source file and write to the remote destination within VB, not really the ideal way to do this but if VB is all you have available...

  5. #5
    Technojunkie
    Join Date
    May 2004
    Location
    Up North
    Posts
    2,580
    Thanks
    239
    Thanked
    213 times in 138 posts

    Re: VisualBasic - Copy cache?

    Open it with the no buffering flag:

    Public Const FILE_FLAG_NO_BUFFERING As Integer = &H20000000
    Chrome & Firefox addons for BBC News
    Follow me @twitter

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. HEXUS mistake w/ AMD's Quad-Core cache.
    By Super XP in forum HEXUS Reviews
    Replies: 43
    Last Post: 01-02-2007, 11:38 AM
  2. PRobably an old chestnut - AMD X2, cache sizes and overclocking
    By cah in forum PC Hardware and Components
    Replies: 20
    Last Post: 15-05-2005, 11:06 PM
  3. 8mb cache more important than size?
    By Stewart in forum PC Hardware and Components
    Replies: 11
    Last Post: 27-10-2003, 02:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •