170 lines
4.7 KiB
Plaintext
Executable File
170 lines
4.7 KiB
Plaintext
Executable File
----
|
|
-- File:: rpf_profile.rbs
|
|
-- Description:: Profile RPF building/extraction operations.
|
|
--
|
|
-- Author:: David Muir <david.muir@rockstarnorth.com>
|
|
-- Date:: 20 September 2010
|
|
--
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- Uses
|
|
-----------------------------------------------------------------------------
|
|
-- None
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- File Globals
|
|
-----------------------------------------------------------------------------
|
|
local iterations = 10
|
|
local compress = false
|
|
local rpf_filename = "x:\\gta5\\assets\\export\\levels\\gta5\\navmeshes0.rpf"
|
|
local out_filename = "x:\\gta5\\assets\\export\\levels\\gta5\\navmeshes0.copy.rpf"
|
|
local temp_dir = "c:\\temp\\"
|
|
local mount_point = "pack:/"
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- Functions
|
|
-----------------------------------------------------------------------------
|
|
|
|
--
|
|
-- Parse any unit test option command line parameters.
|
|
--
|
|
function set_parameters( )
|
|
|
|
in_iterations = get_param( "iterations" )
|
|
if ( in_iterations ~= nil ) then
|
|
iterations = 0 + in_iterations
|
|
end
|
|
|
|
in_compress = get_param( "compress" )
|
|
if ( in_compress ~= nil ) then
|
|
compress = ( "true" == in_compress )
|
|
end
|
|
|
|
print( "Test Parameters" )
|
|
print( "iterations = " .. iterations )
|
|
if ( compress ) then
|
|
print( "compress = true" )
|
|
else
|
|
print( "compress = false" )
|
|
end
|
|
end
|
|
|
|
--
|
|
-- Run one test iteration on a single RPF file. Returns three values; the
|
|
-- first being the file find time, then extract time, third being the rebuild time.
|
|
--
|
|
function test_rpf( filename )
|
|
|
|
-- Extract
|
|
mount_pack( filename, mount_point )
|
|
local find_start = os.clock()
|
|
local files = find_files( mount_point .. "*.*" )
|
|
local find_duration = ( os.clock() - find_start )
|
|
|
|
local extract_start = os.clock()
|
|
for key, value in files do
|
|
|
|
local file = get_filename_from_path( value )
|
|
copy_file( mount_point .. file, temp_dir .. file )
|
|
end
|
|
|
|
unmount_pack( filename )
|
|
local extract_duration = ( os.clock() - extract_start )
|
|
|
|
-- Rebuild
|
|
local rebuild_start = os.clock()
|
|
if ( compress ) then
|
|
start_pack()
|
|
else
|
|
start_uncompressed_pack()
|
|
end
|
|
|
|
for key, value in files do
|
|
|
|
local file = get_filename_from_path( value )
|
|
add_to_pack( temp_dir .. file )
|
|
end
|
|
save_pack( out_filename )
|
|
close_pack()
|
|
local rebuild_duration = ( os.clock() - rebuild_start )
|
|
|
|
return find_duration, extract_duration, rebuild_duration
|
|
end
|
|
|
|
--
|
|
-- Return average of all values in specified array.
|
|
--
|
|
function average( data, count )
|
|
|
|
local total = 0
|
|
for i = 1, count do
|
|
total = total + data[i]
|
|
end
|
|
|
|
return ( total / count )
|
|
end
|
|
|
|
--
|
|
-- Return the minimum and maximum of all values in specified array.
|
|
function maxmin( data, count )
|
|
|
|
local min = 99999999
|
|
local max = -99999999
|
|
for i = 1, count do
|
|
if ( data[i] < min ) then
|
|
min = data[i]
|
|
end
|
|
if ( data[i] > max ) then
|
|
max = data[i]
|
|
end
|
|
end
|
|
|
|
return min, max
|
|
end
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- Entry-Point
|
|
-----------------------------------------------------------------------------
|
|
|
|
set_parameters()
|
|
create_leadingpath( temp_dir .. "blah.txt" )
|
|
|
|
local index = 0
|
|
local find_durations = {}
|
|
local extract_durations = {}
|
|
local rebuild_durations = {}
|
|
|
|
for index = 1, iterations do
|
|
|
|
f, e, b = test_rpf( rpf_filename )
|
|
|
|
find_durations[index] = f
|
|
extract_durations[index] = e
|
|
rebuild_durations[index] = b
|
|
|
|
display( string.format( "[%d] Find duration (s) : %.3f", index, f ) )
|
|
display( string.format( "[%d] Extract duration (s): %.3f", index, e ) )
|
|
display( string.format( "[%d] Rebuild duration (s): %.3f", index, b ) )
|
|
end
|
|
|
|
print( "Find Results:" )
|
|
min, max = maxmin( find_durations, iterations )
|
|
print( string.format( "\tAverage duration (s): %.3f", average( find_durations, iterations ) ) )
|
|
print( string.format( "\tMinimum duration (s): %.3f", min ) )
|
|
print( string.format( "\tMaximum duration (s): %.3f", max ) )
|
|
|
|
print( "Extraction Results:" )
|
|
min, max = maxmin( extract_durations, iterations )
|
|
print( string.format( "\tAverage duration (s): %.3f", average( extract_durations, iterations ) ) )
|
|
print( string.format( "\tMinimum duration (s): %.3f", min ) )
|
|
print( string.format( "\tMaximum duration (s): %.3f", max ) )
|
|
|
|
print( "Rebuild Results:" )
|
|
min, max = maxmin( rebuild_durations, iterations )
|
|
print( string.format( "\tAverage duration (s): %.3f", average( rebuild_durations, iterations ) ) )
|
|
print( string.format( "\tMinimum duration (s): %.3f", min ) )
|
|
print( string.format( "\tMaximum duration (s): %.3f", max ) )
|
|
|
|
-- rpf_profile.rbs
|