/* Timestamp, measured in microseconds since the Unix epoch. */
typedef int64_t bluesky_time;
+/* High-resolution timer, measured in nanoseconds. */
+typedef int64_t bluesky_time_hires;
+bluesky_time_hires bluesky_now_hires();
+
/* In-memory representation of an inode within a Blue Sky server. This
* corresponds roughly with information that is committed to persistent
* storage. Locking/refcounting rules:
void bluesky_file_write(BlueSkyInode *inode, uint64_t offset,
const char *data, gint len)
{
+ g_print("Start write: %ld\n", bluesky_now_hires());
g_return_if_fail(inode->type == BLUESKY_REGULAR);
g_return_if_fail(offset < inode->size);
g_return_if_fail(len <= inode->size - offset);
bluesky_inode_update_ctime(inode, 1);
bluesky_inode_flush(inode->fs, inode);
+ g_print("End write: %ld\n", bluesky_now_hires());
}
void bluesky_file_read(BlueSkyInode *inode, uint64_t offset,
/* Miscellaneous useful functions that don't really fit anywhere else. */
+bluesky_time_hires bluesky_now_hires()
+{
+ struct timespec time;
+
+ if (clock_gettime(CLOCK_REALTIME, &time) != 0) {
+ perror("clock_gettime");
+ return 0;
+ }
+
+ return (int64_t)(time.tv_sec) * 1000000000 + time.tv_nsec;
+}
/* Convert a UTF-8 string to lowercase. This can be used to implement
* case-insensitive lookups and comparisons, by normalizing all values to