Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Comparing TypedDictionary to Hash
- *
- * Can easily be switched platform-specifically as interface is identical
- * I tried the tests with Top having 1 subclass, and Top having 8 subclasses, same results
- */
- //SAMPLE DATA:
- Debug.hx:21: Dict Set String : 1194
- Debug.hx:21: Dict Set Class : 519
- Debug.hx:21: Hash Set : 3614
- Debug.hx:21: Dict Get String : 778
- Debug.hx:21: Dict Get Class : 390
- Debug.hx:21: Hash Get : 3334
- Debug.hx:21: Dict Set String : 1223
- Debug.hx:21: Dict Set Class : 515
- Debug.hx:21: Hash Set : 3639
- Debug.hx:21: Dict Get String : 816
- Debug.hx:21: Dict Get Class : 395
- Debug.hx:21: Hash Get : 3540
- Debug.hx:21: Dict Set String : 1184
- Debug.hx:21: Dict Set Class : 557
- Debug.hx:21: Hash Set : 3894
- Debug.hx:21: Dict Get String : 802
- Debug.hx:21: Dict Get Class : 397
- Debug.hx:21: Hash Get : 3526
- //THE TEST
- package ;
- import flash.Lib;
- import flash.utils.TypedDictionary;
- import libTF.utils.Debug;
- class Main
- {
- static function main()
- {
- //traces
- FlashConnect.redirect();
- //create dicts
- var c0:TypedDictionary < String, Top > = new TypedDictionary < String, Top > ();
- var c1:TypedDictionary < Class<Top>, Top > = new TypedDictionary < Class<Top>, Top > ();
- var c2:Hash<Top> = new Hash<Top>();
- //vars for use in loop
- var i:Int;
- var b:Top = new B();
- //run tests
- i = 0;
- Debug.startBench();
- while (i < 10000000)
- {
- c0.set("B", b);
- i++;
- }
- Debug.getBench("Dict Set String");
- i = 0;
- Debug.startBench();
- while (i < 10000000)
- {
- c1.set(B, b);
- i++;
- }
- Debug.getBench("Dict Set Class");
- i = 0;
- Debug.startBench();
- while (i < 10000000)
- {
- c2.set("B", b);
- i++;
- }
- Debug.getBench("Hash Set");
- i = 0;
- Debug.startBench();
- while (i < 10000000)
- {
- c0.get("B");
- i++;
- }
- Debug.getBench("Dict Get String");
- i = 0;
- Debug.startBench();
- while (i < 10000000)
- {
- c1.get(B);
- i++;
- }
- Debug.getBench("Dict Get Class");
- i = 0;
- Debug.startBench();
- while (i < 10000000)
- {
- c2.get("B");
- i++;
- }
- Debug.getBench("Hash Get");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement