--[[----------------------------------------------------------------------------

KSBlondeLargeTableTest.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2010 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remain the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

------------------------------------------------------------------------------]]

-- GRUNGE [epoley 2011-01-18]: There's not a good way to have a test case require
-- a non-test-case file, so I've made a separate test case for testing the performance
-- of encoding large tables, so as to not clutter the other test case file.

local largeTable = {
		collections = {
			{
				id = "2143657",
				lcName = "111 east buttles street",
				name = "111 East Buttles Street",
			},
			{
				id = "2143669",
				lcName = "1517 walnut street",
				name = "1517 Walnut Street",
			},
			{
				id = "2143663",
				lcName = "315 west meadowbrook",
				name = "315 West Meadowbrook",
			},
			{
				id = "2143675",
				lcName = "5849 el dorado street",
				name = "5849 El Dorado Street",
			},
			{
				id = "2176317",
				lcName = "adrian west",
				name = "Adrian West",
			},
			{
				id = "2143681",
				lcName = "aerial view",
				name = "Aerial View",
			},
			{
				id = "2143687",
				lcName = "agate beach",
				name = "Agate Beach",
			},
			{
				id = "2143928",
				lcName = "ageratium",
				name = "Ageratium",
			},
			{
				id = "2144079",
				lcName = "albany western regional usda lab",
				name = "Albany Western Regional USDA Lab",
			},
			{
				id = "2144085",
				lcName = "alden dow studio",
				name = "Alden Dow Studio",
			},
			{
				id = "2144091",
				lcName = "alex bangs",
				name = "Alex Bangs",
			},
			{
				id = "2144097",
				lcName = "amaryllis amigo",
				name = "Amaryllis Amigo",
			},
			{
				id = "2144115",
				lcName = "amaryllis baby star",
				name = "Amaryllis Baby Star",
			},
			{
				id = "2144103",
				lcName = "amaryllis la paz cybister",
				name = "Amaryllis La Paz Cybister",
			},
			{
				id = "2144109",
				lcName = "amaryllis razzmatazz",
				name = "Amaryllis Razzmatazz",
			},
			{
				id = "2144121",
				lcName = "amy zwelling",
				name = "Amy Zwelling",
			},
			{
				id = "2144127",
				lcName = "art fairs",
				name = "Art Fairs",
			},
			{
				id = "2144133",
				lcName = "au train bay",
				name = "Au Train Bay",
			},
			{
				id = "2144139",
				lcName = "aunt betty",
				name = "Aunt Betty",
			},
			{
				id = "2144145",
				lcName = "aunt mabel",
				name = "Aunt Mabel",
			},
			{
				id = "2144151",
				lcName = "autumn",
				name = "Autumn",
			},
			{
				id = "2144157",
				lcName = "azalea",
				name = "Azalea",
			},
			{
				id = "2144169",
				lcName = "baptism",
				name = "Baptism",
			},
			{
				id = "2144175",
				lcName = "barbara haught",
				name = "Barbara Haught",
			},
			{
				id = "2144181",
				lcName = "becky strubel",
				name = "Becky Strubel",
			},
			{
				id = "2144187",
				lcName = "bee",
				name = "Bee",
			},
			{
				id = "2144193",
				lcName = "belle isle",
				name = "Belle Isle",
			},
			{
				id = "2144199",
				lcName = "berkeley pier",
				name = "Berkeley Pier",
			},
			{
				id = "2144205",
				lcName = "big mud lake area",
				name = "Big Mud Lake Area",
			},
			{
				id = "2144211",
				lcName = "bill frederick",
				name = "Bill Frederick",
			},
			{
				id = "2144217",
				lcName = "bird",
				name = "Bird",
			},
			{
				id = "2144229",
				lcName = "bj fisher",
				name = "BJ Fisher",
			},
			{
				id = "2144235",
				lcName = "black river recreation area",
				name = "Black River Recreation Area",
			},
			{
				id = "2144241",
				lcName = "blood root",
				name = "Blood Root",
			},
			{
				id = "2144247",
				lcName = "bolinas",
				name = "Bolinas",
			},
			{
				id = "2144253",
				lcName = "brandywine",
				name = "Brandywine",
			},
			{
				id = "2144259",
				lcName = "bridalveil falls",
				name = "Bridalveil Falls",
			},
			{
				id = "2144265",
				lcName = "calumet vc",
				name = "Calumet VC",
			},
			{
				id = "2144271",
				lcName = "carl hamburg",
				name = "Carl Hamburg",
			},
			{
				id = "2144277",
				lcName = "carol epstein",
				name = "Carol Epstein",
			},
			{
				id = "2144283",
				lcName = "carol swinehart",
				name = "Carol Swinehart",
			},
			{
				id = "2144289",
				lcName = "carrie mccall",
				name = "Carrie McCall",
			},
			{
				id = "2145852",
				lcName = "cat",
				name = "Cat",
			},
			{
				id = "2146164",
				lcName = "cathedral rocks",
				name = "Cathedral Rocks",
			},
			{
				id = "2146235",
				lcName = "cathy reitz",
				name = "Cathy Reitz",
			},
			{
				id = "2146271",
				lcName = "cats",
				name = "Cats",
			},
			{
				id = "2146389",
				lcName = "charles rose",
				name = "Charles Rose",
			},
			{
				id = "2146453",
				lcName = "chippewa nature center",
				name = "Chippewa Nature Center",
			},
			{
				id = "2146508",
				lcName = "clouds",
				name = "Clouds",
			},
			{
				id = "2146914",
				lcName = "coast guard station",
				name = "Coast Guard Station",
			},
			{
				id = "2146959",
				lcName = "cooper mine up",
				name = "Cooper Mine UP",
			},
			{
				id = "2147008",
				lcName = "copper harbor",
				name = "Copper Harbor",
			},
			{
				id = "2147045",
				lcName = "craig brown",
				name = "Craig Brown",
			},
			{
				id = "2147088",
				lcName = "crane beach",
				name = "Crane Beach",
			},
			{
				id = "2147128",
				lcName = "crisp point lake superior",
				name = "Crisp Point Lake Superior",
			},
			{
				id = "2147464",
				lcName = "crocus",
				name = "Crocus",
			},
			{
				id = "2146633",
				lcName = "daffodil",
				name = "Daffodil",
			},
			{
				id = "2146665",
				lcName = "dahlia hill",
				name = "Dahlia Hill",
			},
			{
				id = "2176305",
				lcName = "dan solzberg",
				name = "Dan Solzberg",
			},
			{
				id = "2146739",
				lcName = "deer park bay city",
				name = "Deer Park Bay City",
			},
			{
				id = "2149173",
				lcName = "detroit zoo",
				name = "Detroit Zoo",
			},
			{
				id = "2149202",
				lcName = "dick reitz",
				name = "Dick Reitz",
			},
			{
				id = "2149300",
				lcName = "dow chemical",
				name = "Dow Chemical",
			},
			{
				id = "2149326",
				lcName = "dow gardens",
				name = "Dow Gardens",
			},
			{
				id = "2149396",
				lcName = "dow gardens butterfly",
				name = "Dow Gardens Butterfly",
			},
			{
				id = "2149475",
				lcName = "drawf lake iris",
				name = "Drawf Lake Iris",
			},
			{
				id = "2149445",
				lcName = "durfee clan picnic",
				name = "Durfee Clan Picnic",
			},
			{
				id = "2149525",
				lcName = "east tawas sp",
				name = "East Tawas SP",
			},
			{
				id = "2149619",
				lcName = "edmund fitzgerald",
				name = "Edmund Fitzgerald",
			},
			{
				id = "2149665",
				lcName = "el dorado street",
				name = "El Dorado Street",
			},
			{
				id = "2149702",
				lcName = "el portal",
				name = "El Portal",
			},
			{
				id = "2149737",
				lcName = "emeryville mud flats",
				name = "Emeryville Mud Flats",
			},
			{
				id = "2149780",
				lcName = "evergreen highway",
				name = "Evergreen Highway",
			},
			{
				id = "2149878",
				lcName = "finkbeiner roadside park",
				name = "Finkbeiner Roadside Park",
			},
			{
				id = "2150044",
				lcName = "fish hatchery",
				name = "Fish Hatchery",
			},
			{
				id = "2150095",
				lcName = "flood",
				name = "Flood",
			},
			{
				id = "2150158",
				lcName = "flower",
				name = "Flower",
			},
			{
				id = "2150297",
				lcName = "forsythia",
				name = "Forsythia",
			},
			{
				id = "2150362",
				lcName = "frances",
				name = "Frances",
			},
			{
				id = "2150555",
				lcName = "frederick's house",
				name = "Frederick's House",
			},
			{
				id = "2150612",
				lcName = "fungi",
				name = "Fungi",
			},
			{
				id = "2176359",
				lcName = "gary regina",
				name = "Gary Regina",
			},
			{
				id = "2150704",
				lcName = "geese",
				name = "Geese",
			},
			{
				id = "2150736",
				lcName = "gene rose",
				name = "Gene Rose",
			},
			{
				id = "2150658",
				lcName = "geneva",
				name = "Geneva",
			},
			{
				id = "2150782",
				lcName = "golden gate park",
				name = "Golden Gate Park",
			},
			{
				id = "2150851",
				lcName = "goodhart mi",
				name = "Goodhart MI",
			},
			{
				id = "2150917",
				lcName = "grand canyon of the yellowstone",
				name = "Grand Canyon of the Yellowstone",
			},
			{
				id = "2150988",
				lcName = "grand teton national park",
				name = "Grand Teton National Park",
			},
			{
				id = "2151059",
				lcName = "grosehaven lake huron",
				name = "Grosehaven Lake Huron",
			},
			{
				id = "2151199",
				lcName = "half dome",
				name = "Half Dome",
			},
			{
				id = "2151279",
				lcName = "haught",
				name = "Haught",
			},
			{
				id = "2176353",
				lcName = "henry kaiser",
				name = "Henry Kaiser",
			},
			{
				id = "2176293",
				lcName = "houghton lake",
				name = "Houghton Lake",
			},
			{
				id = "2151365",
				lcName = "ice",
				name = "Ice",
			},
			{
				id = "2151435",
				lcName = "ice storm",
				name = "Ice Storm",
			},
			{
				id = "2151525",
				lcName = "janet pratt",
				name = "Janet Pratt",
			},
			{
				id = "2151619",
				lcName = "japanese",
				name = "Japanese",
			},
			{
				id = "2176299",
				lcName = "jd devros",
				name = "JD Devros",
			},
			{
				id = "2151680",
				lcName = "karin johnson",
				name = "Karin Johnson",
			},
			{
				id = "2151747",
				lcName = "killarney provincial park",
				name = "Killarney Provincial Park",
			},
			{
				id = "2151801",
				lcName = "lake of the clouds overlook",
				name = "Lake of the Clouds Overlook",
			},
			{
				id = "2151848",
				lcName = "lake superior beach",
				name = "Lake Superior Beach",
			},
			{
				id = "2151893",
				lcName = "lake superior provincial park",
				name = "Lake Superior Provincial Park",
			},
			{
				id = "2151939",
				lcName = "lake tahoe",
				name = "Lake Tahoe",
			},
			{
				id = "2151977",
				lcName = "lewis river",
				name = "Lewis River",
			},
			{
				id = "2152021",
				lcName = "lucile hamburg",
				name = "Lucile Hamburg",
			},
			{
				id = "2152058",
				lcName = "mackinac bridge",
				name = "Mackinac Bridge",
			},
			{
				id = "2152123",
				lcName = "mcclures beach",
				name = "McClures Beach",
			},
			{
				id = "2152170",
				lcName = "merced river canyon road",
				name = "Merced River Canyon Road",
			},
			{
				id = "2152202",
				lcName = "mirror lake",
				name = "Mirror Lake",
			},
			{
				id = "2152253",
				lcName = "mist trail",
				name = "Mist Trail",
			},
			{
				id = "2152304",
				lcName = "mount tamalpais",
				name = "Mount Tamalpais",
			},
			{
				id = "2176287",
				lcName = "owosso state forest",
				name = "Owosso State Forest",
			},
			{
				id = "2152387",
				lcName = "paulette hayes",
				name = "Paulette Hayes",
			},
			{
				id = "2152427",
				lcName = "peggy mccall",
				name = "Peggy McCall",
			},
			{
				id = "2152479",
				lcName = "pine river",
				name = "Pine River",
			},
			{
				id = "2152601",
				lcName = "polly coote",
				name = "Polly Coote",
			},
			{
				id = "2152523",
				lcName = "porcupine mountains",
				name = "Porcupine Mountains",
			},
			{
				id = "2152878",
				lcName = "presque isle river",
				name = "Presque Isle River",
			},
			{
				id = "2176323",
				lcName = "pushing air",
				name = "Pushing Air",
			},
			{
				id = "2152739",
				lcName = "ralph putney",
				name = "Ralph Putney",
			},
			{
				id = "2152786",
				lcName = "regula baumann",
				name = "Regula Baumann",
			},
			{
				id = "2176275",
				lcName = "rick walker",
				name = "Rick Walker",
			},
			{
				id = "2152943",
				lcName = "rifle river recreation area",
				name = "Rifle River Recreation Area",
			},
			{
				id = "2176329",
				lcName = "rocky mountain national park",
				name = "Rocky Mountain National Park",
			},
			{
				id = "2176281",
				lcName = "saginaw bay",
				name = "Saginaw Bay",
			},
			{
				id = "2153024",
				lcName = "san francisco peace march",
				name = "San Francisco Peace March",
			},
			{
				id = "2153056",
				lcName = "sunset",
				name = "Sunset",
			},
			{
				id = "2153151",
				lcName = "tahquamenon",
				name = "Tahquamenon",
			},
			{
				id = "2176311",
				lcName = "ted killian",
				name = "Ted Killian",
			},
			{
				id = "2176341",
				lcName = "ucb botanical garden",
				name = "UCB Botanical Garden",
			},
			{
				id = "2176347",
				lcName = "vernal falls",
				name = "Vernal Falls",
			},
			{
				id = "2153199",
				lcName = "watkins glen",
				name = "Watkins Glen",
			},
			{
				id = "2153105",
				lcName = "wilderness sp",
				name = "Wilderness SP",
			},
			{
				id = "2153471",
				lcName = "willy baumann",
				name = "Willy Baumann",
			},
			{
				id = "2153241",
				lcName = "yellowstone national park",
				name = "Yellowstone National Park",
			},
			{
				id = "2153305",
				lcName = "yosemite",
				name = "Yosemite",
			},
			{
				id = "2153368",
				lcName = "yosemite entrance view",
				name = "Yosemite Entrance View",
			},
			{
				id = "2153396",
				lcName = "yosemite falls",
				name = "Yosemite Falls",
			},
		},
	}

--==============================================================================

local KSBlondeLargeTableTest = {}

local blonde = require 'blonde'
local debug_timeNow = assert( debug.timeNow )

--------------------------------------------------------------------------------

local function expectError( func, message )

	local success = pcall( func )
	
	if success then
		error( message )
	end

end

--------------------------------------------------------------------------------

local function expectFasterThan( maxSeconds, func )

	local startTime = debug_timeNow()

	func()
	
	local elapsedTime = debug_timeNow() - startTime
	
	if elapsedTime > maxSeconds then
		error( string.format( "Test consumed %.3f seconds, should have completed within %.3f seconds",
			elapsedTime, maxSeconds ) )
	end

end

--------------------------------------------------------------------------------

function KSBlondeLargeTableTest.testEncodeLargeTablePerformance()

	expectFasterThan( 8, function()
		for i = 1, 500 do
			blonde.encode( largeTable )
		end
	end )

end

--------------------------------------------------------------------------------

return KSBlondeLargeTableTest
