Berkeley DB商店太慢了

时间:2016-03-05 07:21:51

标签: c berkeley-db ssd

我正在使用Berkeley DB将数据持久存储在我的程序中。我在我的SSD上测试了它,我的SSD速度是1.4Gb / s用于写入。我测试DB存储速度的程序如下所示(省略错误检查)。

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    let notificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)    
    application.registerUserNotificationSettings(notificationSettings)
    application.registerForRemoteNotifications()

    if let notificationDictionary = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary {
        instantiateViewControllerFromNotification(notificationDictionary)
    }
    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

func instantiateViewControllerFromNotification(notificationDictionary: NSDictionary) {
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let initialViewController = self.window?.rootViewController as! UITabBarController
    initialViewController.selectedIndex = 3

    let navigationController = initialViewController.viewControllers![3] as! UINavigationController
    let detailViewController = storyboard.instantiateViewControllerWithIdentifier("ConversationGroupDetailViewController") as! ConversationGroupDetailViewController

    navigationController.popToRootViewControllerAnimated(false)
    navigationController.pushViewController(detailViewController, animated: false)
}

结果大约是23微秒。它比我想象的要慢得多。有没有人对此有所了解?如何使持久存储与写入SSD一样快。

1 个答案:

答案 0 :(得分:0)

BerkeleyDB在写入后执行fsync以确保保存磁盘上的数据。如果你愿意忍受可能发生灾难性数据丢失的后果(对于使用BDB的临时,非持久性数据存储是可接受的),你可以存根fsync(2)向量(只返回0)