You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

arena_test.cc 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright 2019 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <string>
  17. #include "minddata/dataset/util/arena.h"
  18. #include "common/common.h"
  19. #include "utils/log_adapter.h"
  20. using namespace mindspore::dataset;
  21. class MindDataTestArena : public UT::Common {
  22. public:
  23. MindDataTestArena() {}
  24. };
  25. TEST_F(MindDataTestArena, TestALLFunction) {
  26. std::shared_ptr<Arena> mp;
  27. Status rc = Arena::CreateArena(&mp);
  28. ASSERT_TRUE(rc.IsOk());
  29. std::shared_ptr<Arena> arena = std::dynamic_pointer_cast<Arena>(mp);
  30. std::vector<void *> v;
  31. srand(time(NULL));
  32. for (int i = 0; i < 1000; i++) {
  33. uint64_t sz = rand() % 1048576;
  34. void *ptr = nullptr;
  35. ASSERT_TRUE(mp->Allocate(sz, &ptr));
  36. v.push_back(ptr);
  37. }
  38. for (int i = 0; i < 1000; i++) {
  39. mp->Deallocate(v.at(i));
  40. }
  41. MS_LOG(DEBUG) << *mp;
  42. }