예제 #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            string[] recent_files = new string[23];
            var      src_save     = src;
            var      dbname       = Path.GetFileName(src_save);

            var    i   = 0;
            Random rnd = new Random();

            using (var db = new SimpleStorage.Database(dest))
            {
                foreach (string f in GetFiles(src_save))
                {
                    var _f = f.Substring(src_save.Length + 1);
                    i++;
                    if (i % 71 == 0)
                    {
                        db.Remove(dbname, recent_files[rnd.Next(0, 23)]);
                    }

                    db.Put(dbname, _f, File.ReadAllBytes(f));
                    if (i % 3 == 0)
                    {
                        recent_files[i % 23] = _f;
                    }
                }

                MessageBox.Show("Finished insert/delete, validating data");
                i = 0;
                int k = 0;
                foreach (string f in GetFiles(src))
                {
                    var    _f     = f.Substring(src_save.Length + 1);
                    byte[] result = db.Get(dbname, _f);
                    if (result != null && !result.SequenceEqual(File.ReadAllBytes(f)))
                    {
                        k++;
                    }
                    else
                    {
                        i++;
                    }
                }
                MessageBox.Show(String.Format("{0} başarılı, {1} hatalı", i, k));
            }
        }
예제 #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            var src_save = src;
            var dbname   = Path.GetFileName(src_save);

            int totalbytes = 0;
            int totalfiles = 0;
            int not_found  = 0;
            int success    = 0;
            int error      = 0;

            var stopwatch = new Stopwatch();

            using (var db = new SimpleStorage.Database(dest))
            {
                foreach (string f in GetFiles(src))
                {
                    totalfiles++;
                    var data = File.ReadAllBytes(f);
                    var _f   = f.Substring(src_save.Length + 1);

                    stopwatch.Start();
                    var response = db.Get(dbname, _f);
                    stopwatch.Stop();
                    if (response == null)
                    {
                        not_found++;
                        continue;
                    }
                    totalbytes += response.Length;
                    if (data.SequenceEqual(response))
                    {
                        success++;
                    }
                    else
                    {
                        error++;
                    }
                }
            }

            MessageBox.Show(String.Format("{0} byte toplam boyutunda {1} dosya {2} milisaniyede okundu. Başarılı: {3}, Hatalı: {4}, Bulunamadı: {5}", totalbytes, totalfiles, stopwatch.ElapsedMilliseconds, success, error, not_found));
        }