测试predictionio的性能

Test performance of predictionio

我想测试一种使用 Locust 的算法在预测阶段的性能。

引擎 (REST API) 的查询与此类似:

engine_client = predictionio.EngineClient(url="http://localhost:8003")
print engine_client.send_query({"items": ["10181"], "num": 50, "category": ["31","32"], "blackList":["10184"]})

并使用 java 代码: 并使用 Java 代码:

   @RequestMapping(value = "/bestSeller", method = RequestMethod.GET)

    public String getBestSellerProducts(

        Model model,

        @RequestParam(value = "categoryCode") String categoryCode,

        HttpServletRequest request, HttpServletResponse response)

        throws IOException {

    logger.info("getBestSellerProducts - blackList {}", blackList);

            ...

  }

谁能帮我解决这个问题? 非常感谢。

你需要的代码是这样的。

from locust import HttpLocust, TaskSet, task, events
from locust.stats import RequestStats

class UserBehavior(TaskSet):

def on_start(self):
    """
    Executes for each user at the start
    :return:
    """
    pass

@task
def full_cicle(self):
    """
    Full User cicle
    :return:
    """
    self.recommendation()

def recommendation(self):
    """
    Gets recommendations for user
    :return:
    """
    response = self.client.post(":8000/queries.json", json.dumps({"items": ["10"], "num": 10}),
                                headers={'Content-Type': 'application/json'},name="/recommendation")

class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait=10    # Min time between requests of each user
    max_wait=10    # Max time between requests of each user
    stop_timeout= 100  # Stopping time

并调用类似

的东西
sudo locust --host=http://test.com -f file.py