Difference between revisions of "emRun++"

From SEGGER Wiki
Jump to: navigation, search
(Created page with "emRun++ is a complete C++ standard library for use with any toolchain. It is specifically tweaked for embedded systems and applications. As a modern programming language, C++...")
 
(Memory Footprint Benchmark)
Line 17: Line 17:
 
<source lang="C">
 
<source lang="C">
 
int main(void) {
 
int main(void) {
return 0;
 
}
 
</source>
 
 
=== Hello World ===
 
<source lang="C">
 
#include <strstream>
 
 
int main(void) {
 
std::strstream x;
 
//
 
x << "Hello, world!" << std::endl;
 
return 0;
 
}
 
</source>
 
 
=== Count ===
 
<source lang="C">
 
#include <strstream>
 
 
int main(void) {
 
std::strstream x;
 
//
 
for (int i = 1; i < 10; ++i) {
 
x << i << std::endl;
 
}
 
 
return 0;
 
return 0;
 
}
 
}

Revision as of 16:55, 28 July 2022

emRun++ is a complete C++ standard library for use with any toolchain. It is specifically tweaked for embedded systems and applications. As a modern programming language, C++ is becoming increasingly important in the embedded sector offering developers more and more options. With this in mind, emRun++ is constantly being enhanced to meet the most modern C++ standards.

emRun++ is also part of SEGGER's Embedded Studio IDE. Included in the ready-to-use toolchain and C runtime library of Embedded Studio, it is available out of the box and has all the features that make object-oriented programming (OOP) fast and easy.

Memory Footprint Benchmark

emRun++ is designed for a small memory footprint. A comparison of emRun++ implemented as the SEGGER C++ Library in Embedded Studio to other toolchains and C++ libraries is available at https://www.segger.com/emrunpp

This is the source listing for the test projects. The tests have been designed to measure the memory footprint of template containers with one type and with multiple types.

Empty main

int main(void) {
  return 0;
}

List1

#include <list>

int main(void) {
  std::list<int> x;
  int            total;
  //
  x.push_back(3);
  x.push_back(4);
  x.push_front(1);
  x.push_front(2);
  //
  total = 0;
  for (auto i : x) {
    total += i;
  }
  //
  return total;
}

List2

#include <list>

int main(void) {
  std::list<int>      xi;
  std::list<unsigned> xu;
  int                 total;
  //
  xi.push_back(3);
  xi.push_back(4);
  xi.push_front(1);
  xi.push_front(2);
  //
  xu.push_back(3);
  xu.push_back(4);
  xu.push_front(1);
  xu.push_front(2);
  //
  total = 0;
  for (auto i : xi) {
    total += i;
  }
  for (auto i : xu) {
    total += i;
  }
  //
  return total;
}

Map1

#include <map>

int main(void) {
  std::map<int, int> xii;
  int            total;
  //
  xii[1] = 100;
  xii[2] = 200;
  xii[3] = 300;
  //
  total = 0;
  for (auto i : xii) {
    total += i.second;
  }
  //
  return total;
}

Map2

#include <map>

int main(void) {
  std::map<int, int>           xii;
  std::map<int, unsigned>      xiu;
  std::map<unsigned, int>      xui;
  std::map<unsigned, unsigned> xuu;
  int                          total;
  //
  xii[1] = 100;
  xii[2] = 200;
  xii[3] = 300;
  //
  xiu[1] = 100;
  xiu[2] = 200;
  xiu[3] = 300;
  //
  xui[1] = 100;
  xui[2] = 200;
  xui[3] = 300;
  //
  xuu[1] = 100;
  xuu[2] = 200;
  xuu[3] = 300;
  //
  total = 0;
  for (auto i : xii) {
    total += i.second;
  }
  //
  return total;
}

Set1

#include <set>

int main(void) {
  std::set<int> xi;
  int           total;
  //
  xi.insert(100);
  xi.insert(200);
  xi.insert(300);
  //
  total = 0;
  for (auto i : xi) {
    total += i;
  }
  //
  return total;
}

Set2

#include <set>

int main(void) {
  std::set<int> xi;
  std::set<int> xu;
  int           total;
  //
  xi.insert(100);
  xi.insert(200);
  xi.insert(300);
  //
  xu.insert(100);
  xu.insert(200);
  xu.insert(300);
  //
  total = 0;
  for (auto i : xi) {
    total += i;
  }
  for (auto i : xu) {
    total += i;
  }
  //
  return total;
}