diff options
author | James Dong <jdong@google.com> | 2009-11-11 15:22:44 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2009-11-11 15:26:31 -0800 |
commit | 9d8ed53e28d6de6aba89b12ebc8871d6346e0ba5 (patch) | |
tree | 149c946685d00c047950b963f72b96934ed63ebd | |
parent | ddebbd7b00386d092ab6187682df1eba402fc62a (diff) | |
download | opencore-eclair-sholes-release.tar.gz |
Add some logging to track potential write haltandroid-sdk-2.0.1_r1android-sdk-2.0.1-docs_r1android-2.0.1_r1eclair-sholes-release
-: a tiny bit of performance hit
+: let us track the SD card write halt issue
low-risk change
-rw-r--r-- | oscl/oscl/osclio/src/oscl_file_native.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/oscl/oscl/osclio/src/oscl_file_native.cpp b/oscl/oscl/osclio/src/oscl_file_native.cpp index 368b47506..d3df6f58d 100644 --- a/oscl/oscl/osclio/src/oscl_file_native.cpp +++ b/oscl/oscl/osclio/src/oscl_file_native.cpp @@ -33,6 +33,10 @@ #include "oscl_file_types.h" #include "oscl_file_handle.h" +// FIXME: +// Is 100 milliseconds a good choice for writing out a single +// compressed video frame? +static const int FILE_WRITER_SPEED_TOLERANCE_IN_MILLISECONDS = 100; OsclNativeFile::OsclNativeFile() { @@ -325,7 +329,15 @@ uint32 OsclNativeFile::Write(const OsclAny *buffer, uint32 size, uint32 numeleme #endif if (iFile) { - return fwrite(buffer, OSCL_STATIC_CAST(int32, size), OSCL_STATIC_CAST(int32, numelements), iFile); + struct timeval startTimeVal, endTimeVal; + gettimeofday(&startTimeVal, NULL); + uint32 items = fwrite(buffer, OSCL_STATIC_CAST(int32, size), OSCL_STATIC_CAST(int32, numelements), iFile); + gettimeofday(&endTimeVal, NULL); + long long timeInMicroSeconds = (endTimeVal.tv_sec - startTimeVal.tv_sec) * 1000000LL + (endTimeVal.tv_usec - startTimeVal.tv_usec); + if (timeInMicroSeconds/1000 > FILE_WRITER_SPEED_TOLERANCE_IN_MILLISECONDS) { + LOGW("writing %d bytes takes too long (%lld micro seconds)", items, timeInMicroSeconds); + } + return items; } return 0; } |