115 HBufC8* gBuf = NULL; |
117 HBufC8* gBuf = NULL; |
116 TPtr8 gBufReadPtr(NULL, 0); |
118 TPtr8 gBufReadPtr(NULL, 0); |
117 HBufC8* gBufSec = NULL; |
119 HBufC8* gBufSec = NULL; |
118 TPtr8 gBufWritePtr(NULL, 0); |
120 TPtr8 gBufWritePtr(NULL, 0); |
119 |
121 |
120 const TInt KuStomS = 1000; |
|
121 const TInt KOneK = 1024; |
122 const TInt KOneK = 1024; |
122 const TInt KOneMeg = KOneK * 1024; |
123 const TInt KOneMeg = KOneK * 1024; |
123 const TInt KBigBlockSize = KOneMeg ; |
124 const TInt KBigBlockSize = KOneMeg ; |
124 const TInt KBlockSize = KOneK * 129 ; |
125 const TInt KBlockSize = KOneK * 129 ; |
125 const TInt KWaitRequestsTableSize = 70; |
126 const TInt KWaitRequestsTableSize = 70; |
611 r = aFs.Delete(fileName2); |
615 r = aFs.Delete(fileName2); |
612 TEST(r == KErrNone); |
616 TEST(r == KErrNone); |
613 } |
617 } |
614 |
618 |
615 |
619 |
616 |
|
617 /** Measure the time taken for a big block to be written synchronously |
620 /** Measure the time taken for a big block to be written synchronously |
618 */ |
621 */ |
619 void TimeTakenToWriteBigBlock() |
622 void TimeTakenToWriteBigBlock() |
620 { |
623 { |
621 TTime startTime; |
|
622 TTime endTime; |
|
623 RFile fileWrite; |
624 RFile fileWrite; |
624 |
625 |
625 TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
626 TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
626 TESTERROR(r); |
627 TESTERROR(r); |
627 |
628 |
628 // Calculate how long it takes to write a big block to be able to issue at the right time the concurrent writes |
629 // Calculate how long it takes to write a big block to be able to issue at the right time the concurrent writes |
629 startTime.HomeTime(); |
630 TF32TestTimer timer; |
|
631 timer.Start(); |
630 |
632 |
631 r = fileWrite.Write(gBufWritePtr, KBigBlockSize); |
633 r = fileWrite.Write(gBufWritePtr, KBigBlockSize); |
632 |
634 |
633 endTime.HomeTime(); |
635 timer.Stop(); |
634 |
636 |
635 fileWrite.Close(); |
637 fileWrite.Close(); |
636 |
638 |
637 TESTERROR(r); |
639 TESTERROR(r); |
638 |
640 |
639 gTimeTakenBigBlock = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()/3); |
641 gTimeTakenBigBlock = timer.TimeInMicroSeconds()/3; |
640 |
642 |
641 test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), gTimeTakenBigBlock.Int() / KuStomS); |
643 test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigBlock)); |
642 } |
644 } |
643 |
645 |
644 |
646 |
645 /** Measure the time taken for this file to be written synchronously |
647 /** Measure the time taken for this file to be written synchronously |
646 */ |
648 */ |
647 void TimeTakenToWriteBigFile(TInt aPos) |
649 void TimeTakenToWriteBigFile(TInt aPos) |
648 { |
650 { |
649 TTime startTime; |
|
650 TTime endTime; |
|
651 |
|
652 test((aPos >= 0) && (aPos <= 1)); |
651 test((aPos >= 0) && (aPos <= 1)); |
653 startTime.HomeTime(); |
652 TF32TestTimer timer; |
654 |
653 timer.Start(); |
|
654 |
655 WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads); |
655 WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads); |
656 |
656 |
657 endTime.HomeTime(); |
657 timer.Stop(); |
658 |
658 |
659 gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
659 gTimeTakenBigFile = timer.Time32(); |
660 |
660 |
661 |
661 test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile)); |
662 test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), gTimeTakenBigFile.Int() / KuStomS); |
662 |
663 |
663 gTotalTimeSync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeSync[aPos]) ; |
664 gTotalTimeSync[aPos] = Max((gTimeTakenBigFile.Int()/KuStomS), gTotalTimeSync[aPos]) ; |
|
665 } |
664 } |
666 |
665 |
667 /** Measure the time taken for this file to be written asynchronously |
666 /** Measure the time taken for this file to be written asynchronously |
668 */ |
667 */ |
669 void TimeTakenToWriteBigFileAsync(TInt aPos) |
668 void TimeTakenToWriteBigFileAsync(TInt aPos) |
670 { |
669 { |
671 TTime startTime; |
|
672 TTime endTime; |
|
673 TTime endTime2; |
|
674 TRequestStatus status[KWaitRequestsTableSize]; |
670 TRequestStatus status[KWaitRequestsTableSize]; |
675 RFile bigFile; |
671 RFile bigFile; |
676 |
672 |
677 test((aPos >= 0) && (aPos <= 1)); |
673 test((aPos >= 0) && (aPos <= 1)); |
678 |
674 |
679 startTime.HomeTime(); |
675 TF32TestTimer2 timer; |
|
676 timer.Start(); |
680 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); |
677 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); |
681 endTime.HomeTime(); |
678 timer.Stop(); |
682 |
|
683 |
679 |
684 WaitForAll(status, gBigFileSize, KBigBlockSize); |
680 WaitForAll(status, gBigFileSize, KBigBlockSize); |
685 |
681 timer.Stop2(); |
686 endTime2.HomeTime(); |
682 |
687 |
683 gTimeTakenBigFile = timer.Time32(); |
688 gTimeTakenBigFile=I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
|
689 bigFile.Close(); |
684 bigFile.Close(); |
690 test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), gTimeTakenBigFile.Int() / KuStomS); |
685 test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), timer.TimeInMilliSeconds()); |
691 gTimeTakenBigFile=I64LOW(endTime2.MicroSecondsFrom(startTime).Int64()); |
686 gTimeTakenBigFile = timer.Time2(); |
692 test.Printf(_L("to actually write it: %d ms\n"),gTimeTakenBigFile.Int() / KuStomS); |
687 test.Printf(_L("to actually write it: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile)); |
693 gTotalTimeAsync[aPos] = Max((gTimeTakenBigFile.Int() / KuStomS), gTotalTimeAsync[aPos]) ; |
688 gTotalTimeAsync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeAsync[aPos]) ; |
694 } |
689 } |
695 |
690 |
696 /** Delete content of directory |
691 /** Delete content of directory |
697 |
692 |
698 @param aDir Target directory |
693 @param aDir Target directory |
898 |
893 |
899 /** Reads a small file while writing a big one |
894 /** Reads a small file while writing a big one |
900 |
895 |
901 */ |
896 */ |
902 void TestReadingWhileWriting() |
897 void TestReadingWhileWriting() |
903 { |
898 { |
904 TInt r = 0; |
|
905 TTime time1; |
|
906 TTime time2; |
|
907 |
|
908 time1.HomeTime(); |
|
909 |
|
910 // Write the small file and take the appropriate measures |
899 // Write the small file and take the appropriate measures |
911 WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads); |
900 WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads); |
912 |
901 |
913 // Sync test |
902 // Sync test |
914 TBuf<20> buf=_L("Big Write"); |
903 TBuf<20> buf=_L("Big Write"); |
915 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
904 TInt r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
916 TEST(r == KErrNone); |
905 TEST(r == KErrNone); |
917 |
906 |
918 buf = _L("Small Read"); |
907 buf = _L("Small Read"); |
919 r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
908 r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
920 TEST(r == KErrNone); |
909 TEST(r == KErrNone); |
926 CLIENTWAIT(); |
915 CLIENTWAIT(); |
927 |
916 |
928 gBig.Close(); |
917 gBig.Close(); |
929 gSmall.Close(); |
918 gSmall.Close(); |
930 |
919 |
931 |
920 TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time(); |
932 TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2); |
921 test.Printf(_L("\nSync read done %d ms before the write ended\n"), TF32TestTimer::TimeInMilliSeconds(timeTaken)); |
933 test.Printf(_L("\nSync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
934 TReal time=I64LOW(timeTaken.Int64() / KuStomS); |
|
935 #if !defined(__WINS__) |
922 #if !defined(__WINS__) |
936 // If this condition fails, it means that writing the sync file while fairscheduling a small sync read takes too long |
923 // If this condition fails, it means that writing the sync file while |
937 test.Printf(_L("time: %f\n"), time); |
924 // fairscheduling a small sync read takes too long. Reading small file |
938 // test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); |
925 // should complete first. |
939 test(time > 0); |
926 test(timeTaken > 0); |
940 #endif |
927 #endif |
941 |
928 |
942 // Async test |
929 // Async test |
943 TRequestStatus status[KWaitRequestsTableSize]; |
930 TRequestStatus status[KWaitRequestsTableSize]; |
944 TRequestStatus status2[2]; |
931 TRequestStatus status2[2]; |
946 |
933 |
947 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize ,status); |
934 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize ,status); |
948 ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 ); |
935 ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 ); |
949 |
936 |
950 WaitForAll(status2,KBlockSize , KBlockSize ); |
937 WaitForAll(status2,KBlockSize , KBlockSize ); |
951 time1.HomeTime(); |
938 |
|
939 TF32TestTimer timer; |
|
940 timer.Start(); |
952 |
941 |
953 WaitForAll(status,gBigFileSize, KBigBlockSize); |
942 WaitForAll(status,gBigFileSize, KBigBlockSize); |
954 |
943 |
955 time2.HomeTime(); |
944 timer.Stop(); |
956 bigFile.Close(); |
945 bigFile.Close(); |
957 smallFile.Close(); |
946 smallFile.Close(); |
958 |
947 |
959 timeTaken = time2.MicroSecondsFrom(time1); |
948 timeTaken = timer.Time(); |
960 |
949 |
961 test.Printf(_L("\nAsync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
950 test.Printf(_L("\nAsync read done %d ms before the write ended\n"), timer.TimeInMilliSeconds()); |
962 time = I64LOW(timeTaken.Int64() / KuStomS); |
|
963 |
951 |
964 #if !defined(__WINS__) |
952 #if !defined(__WINS__) |
965 if (!Is_HVFS(TheFs, gDrive)) |
953 if (!Is_HVFS(TheFs, gDrive)) |
966 { |
954 { |
967 // If this condition fails, it means that writing the async file while fairscheduling a small async read takes too long |
955 // If this condition fails, it means that writing the async file while fairscheduling a small async read takes too long |
968 test.Printf(_L("time: %f\n"), time); |
|
969 test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
956 test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
970 // test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) ); |
957 test(timeTaken > 0); |
971 test(time > 0); |
|
972 } |
958 } |
973 #endif |
959 #endif |
974 } |
960 } |
975 |
961 |
976 /** Writes a small file while writing a big one |
962 /** Writes a small file while writing a big one |
977 |
963 |
978 */ |
964 */ |
979 void TestWritingWhileWriting() |
965 void TestWritingWhileWriting() |
980 { |
966 { |
981 TInt r = 0; |
967 TInt r = 0; |
982 TTime time1; |
|
983 TTime time2; |
|
984 |
968 |
985 // Sync test |
969 // Sync test |
986 TBuf<20> buf = _L("Big Write II"); |
970 TBuf<20> buf = _L("Big Write II"); |
987 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
971 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
988 TEST(r == KErrNone); |
972 TEST(r == KErrNone); |
998 CLIENTWAIT(); |
982 CLIENTWAIT(); |
999 |
983 |
1000 gBig.Close(); |
984 gBig.Close(); |
1001 gSmall.Close(); |
985 gSmall.Close(); |
1002 |
986 |
1003 TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2); |
987 TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time(); |
1004 test.Printf(_L("\nSync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
988 test.Printf(_L("\nSync write done %d ms before the big write ended\n"), gTestTimer.TimeInMilliSeconds()); |
1005 TReal time=I64LOW(timeTaken.Int64() / KuStomS); |
|
1006 #if !defined(__WINS__) |
989 #if !defined(__WINS__) |
1007 // If this condition fails, it means that writing the sync file while fairscheduling a small sync write takes too long |
990 // If this condition fails, it means that writing the sync file while |
1008 test.Printf(_L("time: %f\n"), time); |
991 // fairscheduling a small sync write takes too long |
1009 // test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); |
992 test(timeTaken > 0); |
1010 test(time > 0); |
|
1011 #endif |
993 #endif |
1012 |
994 |
1013 // Async test |
995 // Async test |
1014 TRequestStatus status[KWaitRequestsTableSize]; |
996 TRequestStatus status[KWaitRequestsTableSize]; |
1015 TRequestStatus status2[1]; |
997 TRequestStatus status2[1]; |
1016 RFile bigFile, smallFile; |
998 RFile bigFile, smallFile; |
1017 |
999 |
1018 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
1000 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
1019 WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2); |
1001 WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2); |
1020 WaitForAll(status2,gSmallFileSize, KBlockSize); |
1002 WaitForAll(status2,gSmallFileSize, KBlockSize); |
1021 time1.HomeTime(); |
1003 TF32TestTimer timer; |
|
1004 timer.Start(); |
1022 WaitForAll(status, gBigFileSize, KBigBlockSize); |
1005 WaitForAll(status, gBigFileSize, KBigBlockSize); |
1023 time2.HomeTime(); |
1006 timer.Stop(); |
1024 |
1007 |
1025 timeTaken = time2.MicroSecondsFrom(time1); |
1008 timeTaken = timer.Time(); |
1026 test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
1009 test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),timer.TimeInMilliSeconds()); |
1027 time=I64LOW(timeTaken.Int64() / KuStomS); |
|
1028 #if !defined(__WINS__) |
1010 #if !defined(__WINS__) |
1029 if (!Is_HVFS(TheFs, gDrive)) |
1011 if (!Is_HVFS(TheFs, gDrive)) |
1030 { |
1012 { |
1031 // If this condition fails, it means that writing the async file while fairscheduling a small async write takes too long |
1013 // If this condition fails, it means that writing the async file while fairscheduling a small async write takes too long |
1032 test.Printf(_L("time: %f\n"), time); |
|
1033 test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
1014 test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
1034 // test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) ); |
1015 test(timeTaken > 0); |
1035 test(time > 0); |
|
1036 } |
1016 } |
1037 #endif |
1017 #endif |
1038 bigFile.Close(); |
1018 bigFile.Close(); |
1039 smallFile.Close(); |
1019 smallFile.Close(); |
1040 } |
1020 } |
1064 CLIENTWAIT(); |
1042 CLIENTWAIT(); |
1065 |
1043 |
1066 gBig.Close(); |
1044 gBig.Close(); |
1067 gSmall.Close(); |
1045 gSmall.Close(); |
1068 |
1046 |
1069 TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1); |
1047 TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time(); |
1070 test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
1048 test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken)); |
1071 |
1049 |
1072 // Async test |
1050 // Async test |
1073 TRequestStatus status[KWaitRequestsTableSize]; |
1051 TRequestStatus status[KWaitRequestsTableSize]; |
1074 TRequestStatus status2[KWaitRequestsTableSize]; |
1052 TRequestStatus status2[KWaitRequestsTableSize]; |
1075 RFile bigFile, bigFile2; |
1053 RFile bigFile, bigFile2; |
1076 |
1054 |
1077 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
1055 WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
1078 WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2); |
1056 WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2); |
1079 WaitForAll(status, gBigFileSize, KBigBlockSize); |
1057 WaitForAll(status, gBigFileSize, KBigBlockSize); |
1080 time1.HomeTime(); |
1058 TF32TestTimer timer; |
|
1059 timer.Start(); |
1081 WaitForAll(status2, gBigFileSize, KBigBlockSize); |
1060 WaitForAll(status2, gBigFileSize, KBigBlockSize); |
1082 time2.HomeTime(); |
1061 timer.Stop(); |
1083 |
1062 |
1084 timeTaken = time2.MicroSecondsFrom(time1); |
1063 timeTaken = timer.Time(); |
1085 test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
1064 test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken)); |
1086 bigFile.Close(); |
1065 bigFile.Close(); |
1087 bigFile2.Close(); |
1066 bigFile2.Close(); |
1088 } |
1067 } |
1089 |
1068 |
1090 /** Reads the file that is being written |
1069 /** Reads the file that is being written |
1091 |
1070 |
1092 */ |
1071 */ |
1093 void TestReadingWhileWritingSameFile() |
1072 void TestReadingWhileWritingSameFile() |
1094 { |
1073 { |
1095 TInt r = 0; |
1074 TInt r = 0; |
1096 TTime time1; |
1075 TF32TestTimer timer; |
1097 |
1076 |
1098 time1.HomeTime(); |
1077 timer.Start(); |
1099 |
1078 |
1100 // Sync test |
1079 // Sync test |
1101 TBuf<20> buf = _L("Big Write IV"); |
1080 TBuf<20> buf = _L("Big Write IV"); |
1102 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
1081 r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
1103 TEST(r == KErrNone); |
1082 TEST(r == KErrNone); |