예제 #1
0
 @Test
 public void findAll() throws IOException {
   long startTiem = System.currentTimeMillis();
   // System.out.println("全部数据    "+bakFiles.getCount());
   // DBCursor cursor = bakFiles.find();
   long endTime = System.currentTimeMillis();
   ReadWriteFile.creatTxtFile("记录");
   ReadWriteFile.writeTxtFile(
       "查询 全部 的数据bakFiles.find().size() 总共有 "
           + bakFiles.find().size()
           + "  数据  查询完毕"
           + "本次操作消费   "
           + (endTime - startTiem)
           + "  毫秒");
 }
예제 #2
0
  @Test
  public void insert() throws Exception, IllegalAccessException {
    long startTiem = System.currentTimeMillis();
    FileBean fileBean = new FileBean();
    DBObject bakfile = null;

    Random random = new Random();
    int idx = 0;
    for (int i = 0; i < 50; i++) { // 设置不同部门
      fileBean.setSecretDepartment("研发" + i);
      for (int j = 0; j < 20; j++) { // 设置不同的客户端

        fileBean.setClientId(i + "C" + j);
        fileBean.setUsername(i + "star" + j);
        fileBean.setHostName(i + "H" + j);
        fileBean.setIp("192.168.0.1");
        fileBean.setMac("ADEW-@#DD-SSS@");
        for (int n = 0; n < 50; n++) { // 设置不同的文件

          fileBean.setFileId(i + "F" + j + "F" + n);
          fileBean.setContentName(i + "F" + j + "xlk" + n);
          fileBean.setSecretPerson(i + "F" + j + "许立亢" + n);
          fileBean.setSecretStatus(new Integer(random.nextInt(5)));
          fileBean.setSecretLevel(new Integer(random.nextInt(5)));
          fileBean.setTimelimitType(new Integer(random.nextInt(5)));
          fileBean.setSecretTime(new Timestamp(System.currentTimeMillis()));
          for (int m = 0; m < 20; m++) {

            fileBean.setBackPath("D:\\ProgramFiles");
            fileBean.setInval(random.nextInt(2)); // 设置有效无效
            bakfile = TestCount.bean2DBObject(fileBean);
            bakFiles.save(bakfile).getN();
            idx++;
          }
        }
      }
    }
    long endTime = System.currentTimeMillis();
    System.out.println("插入  " + idx + "  条数据完毕");
    System.out.println("本次操作消费   " + (endTime - startTiem) + "  毫秒");

    ReadWriteFile.creatTxtFile("记录");
    ReadWriteFile.writeTxtFile(
        "插入  " + idx + "  数据完毕" + "本次操作消费   " + (endTime - startTiem) + "  毫秒");
  }