Browse Source

remove cached bench (#7900)

Nikolay Kim 2 years ago
parent
commit
1d45fbede4

+ 0 - 2
frameworks/Rust/ntex/benchmark_config.json

@@ -42,7 +42,6 @@
         "db_url": "/db",
         "db_url": "/db",
         "query_url": "/query?q=",
         "query_url": "/query?q=",
         "update_url": "/update?q=",
         "update_url": "/update?q=",
-        "cached_query_url": "/cached_query?q=",
         "port": 8080,
         "port": 8080,
         "approach": "Realistic",
         "approach": "Realistic",
         "classification": "Micro",
         "classification": "Micro",
@@ -63,7 +62,6 @@
         "db_url": "/db",
         "db_url": "/db",
         "query_url": "/query?q=",
         "query_url": "/query?q=",
         "update_url": "/update?q=",
         "update_url": "/update?q=",
-        "cached_query_url": "/cached_query?q=",
         "port": 8080,
         "port": 8080,
         "approach": "Realistic",
         "approach": "Realistic",
         "classification": "Micro",
         "classification": "Micro",

+ 0 - 2
frameworks/Rust/ntex/config.toml

@@ -31,7 +31,6 @@ versus = ""
 urls.db = "/db"
 urls.db = "/db"
 urls.query = "/query?q="
 urls.query = "/query?q="
 urls.update = "/update?q="
 urls.update = "/update?q="
-urls.cached_query = "/cached_query?q="
 urls.fortune = "/fortunes"
 urls.fortune = "/fortunes"
 approach = "Realistic"
 approach = "Realistic"
 classification = "Micro"
 classification = "Micro"
@@ -48,7 +47,6 @@ urls.db = "/db"
 urls.query = "/query?q="
 urls.query = "/query?q="
 urls.update = "/update?q="
 urls.update = "/update?q="
 urls.fortune = "/fortunes"
 urls.fortune = "/fortunes"
-urls.cached_query = "/cached_query?q="
 approach = "Realistic"
 approach = "Realistic"
 classification = "Micro"
 classification = "Micro"
 database = "Postgres"
 database = "Postgres"

+ 0 - 27
frameworks/Rust/ntex/src/db.rs

@@ -29,7 +29,6 @@ pub struct PgConnection {
     rng: WyRand,
     rng: WyRand,
     updates: Vec<Statement>,
     updates: Vec<Statement>,
     buf: RefCell<BytesMut>,
     buf: RefCell<BytesMut>,
-    cached: Vec<World>,
 }
 }
 
 
 impl PgConnection {
 impl PgConnection {
@@ -62,21 +61,11 @@ impl PgConnection {
         }
         }
         let world = cl.prepare("SELECT * FROM world WHERE id=$1").await.unwrap();
         let world = cl.prepare("SELECT * FROM world WHERE id=$1").await.unwrap();
 
 
-        let all_worlds = cl.prepare("SELECT * FROM world ORDER by id").await.unwrap();
-        let mut cached = Vec::new();
-        for row in cl.query_raw(&all_worlds, &[]).await.unwrap() {
-            cached.push(World {
-                id: row.get(0),
-                randomnumber: row.get(1),
-            });
-        }
-
         PgConnection {
         PgConnection {
             cl,
             cl,
             fortune,
             fortune,
             world,
             world,
             updates,
             updates,
-            cached,
             rng: WyRand::new(),
             rng: WyRand::new(),
             buf: RefCell::new(BytesMut::with_capacity(65535)),
             buf: RefCell::new(BytesMut::with_capacity(65535)),
         }
         }
@@ -167,22 +156,6 @@ impl PgConnection {
         body.split().freeze()
         body.split().freeze()
     }
     }
 
 
-    pub fn cached_query(&self, num: usize) -> Bytes {
-        let mut rng = nanorand::tls_rng();
-
-        let mut body = self.buf.borrow_mut();
-        utils::reserve(&mut body);
-        body.put_u8(b'[');
-        (0..num).for_each(|_| {
-            let w_id = rng.generate::<usize>() % 10_000;
-            self.cached[w_id].to_bytes_mut(&mut *body);
-            body.put_u8(b',');
-        });
-        let idx = body.len() - 1;
-        body[idx] = b']';
-        body.split().freeze()
-    }
-
     pub async fn tell_fortune(&self) -> Bytes {
     pub async fn tell_fortune(&self) -> Bytes {
         let fut = self.cl.query_raw(&self.fortune, &[]);
         let fut = self.cl.query_raw(&self.fortune, &[]);
 
 

+ 0 - 10
frameworks/Rust/ntex/src/main_db.rs

@@ -61,16 +61,6 @@ impl Service<Request> for App {
                         .insert(CONTENT_TYPE, utils::HDR_JSON_CONTENT_TYPE);
                         .insert(CONTENT_TYPE, utils::HDR_JSON_CONTENT_TYPE);
                     Ok(res)
                     Ok(res)
                 }
                 }
-                "/cached_query" => {
-                    let worlds = self
-                        .0
-                        .cached_query(utils::get_query_param(req.uri().query()));
-                    let mut res = HttpResponse::with_body(StatusCode::OK, worlds.into());
-                    res.headers_mut().insert(SERVER, utils::HDR_SERVER);
-                    res.headers_mut()
-                        .insert(CONTENT_TYPE, utils::HDR_JSON_CONTENT_TYPE);
-                    Ok(res)
-                }
                 _ => Ok(Response::new(StatusCode::NOT_FOUND)),
                 _ => Ok(Response::new(StatusCode::NOT_FOUND)),
             }
             }
         })
         })