📄 test.cpp
字号:
<< (et-st)*10 << "ms\n";// gsCount = 100000; for (i = 0; i < NAME_COUNT; ++i) { sprintf(b+4, "%ds", i); names[i] = b; } st = times(&spare); for (i = 0; i < gsCount; ++i) { e1.set<String>(names[i % NAME_COUNT], b); } et = times(&spare); cout << "Event: " << gsCount << " setStrings: " << (et-st)*10 << "ms\n"; st = times(&spare); j = 0; for (i = 0; i < gsCount; ++i) { if (i%4==0) sprintf(b+4, "%ds", i); j += e1.get<String>(names[i % NAME_COUNT]).size(); } et = times(&spare); cout << "Event: " << gsCount << " getStrings: " << (et-st)*10 << "ms (result: " << j << ")\n"; st = times(&spare); for (i = 0; i < 1000; ++i) { Event e11(e1); (void)e11.get<String>(names[i % NAME_COUNT]); } et = times(&spare); cout << "Event: 1000 copy ctors of " << e1.getStorageSize() << "-byte element: " << (et-st)*10 << "ms\n"; st = times(&spare); for (i = 0; i < 1000; ++i) { Event e11(e1); (void)e11.get<String>(names[i % NAME_COUNT]); (void)e11.set<String>(names[i % NAME_COUNT], "blah"); } et = times(&spare); cout << "Event: 1000 copy ctors plus set<String> of " << e1.getStorageSize() << "-byte element: " << (et-st)*10 << "ms\n";// gsCount = 1000000; st = times(&spare); for (i = 0; i < gsCount; ++i) { Event e21("dummy", i, 0, MIN_SUBORDERING); } et = times(&spare); cout << "Event: " << gsCount << " event ctors alone: " << (et-st)*10 << "ms\n"; st = times(&spare); for (i = 0; i < gsCount; ++i) { std::string s0("dummy"); std::string s1 = s0; } et = times(&spare); cout << "Event: " << gsCount << " string ctors+assignents: " << (et-st)*10 << "ms\n"; st = times(&spare); for (i = 0; i < gsCount; ++i) { Event e21("dummy", i, 0, MIN_SUBORDERING); (void)e21.getAbsoluteTime(); (void)e21.getDuration(); (void)e21.getSubOrdering(); } et = times(&spare); cout << "Event: " << gsCount << " event ctors plus getAbsTime/Duration/SubOrdering: " << (et-st)*10 << "ms\n"; st = times(&spare); for (i = 0; i < gsCount; ++i) { Event e21("dummy", i, 0, MIN_SUBORDERING); (void)e21.getAbsoluteTime(); (void)e21.getDuration(); (void)e21.getSubOrdering(); e21.set<Int>(names[0], 40); (void)e21.get<Int>(names[0]); } et = times(&spare); cout << "Event: " << gsCount << " event ctors plus one get/set and getAbsTime/Duration/SubOrdering: " << (et-st)*10 << "ms\n"; #else cout << "Skipping test speed of Event\n";#endif // TEST_SPEED#ifdef NOT_DEFINED cout << "Testing segment shrinking\n"; Segment segment(5, 0); unsigned int nbBars = segment.getNbBars(); cout << "Segment nbBars : " << nbBars << endl; if (nbBars != 5) { cerr << "%%%ERROR : segment nbBars should be 5\n"; } Segment::iterator iter = segment.end(); --iter; cout << "Last segment el. time : " << (*iter)->getAbsoluteTime() << endl; cout << "Shrinking segment to 3 bars : \n"; segment.setNbBars(3); nbBars = segment.getNbBars(); cout << "Segment new nbBars : " << nbBars << endl; if (nbBars != 3) { cerr << "%%%ERROR : segment new nbBars should be 3\n"; }#endif // NOT_DEFINED#ifdef TEST_NOTATION_TYPES cout << "Testing duration-list stuff\n"; cout << "2/4..." << endl; TimeSignature ts(2,4); DurationList dlist; ts.getDurationListForInterval (dlist, 1209, ts.getBarDuration() - Note(Note::Semiquaver, true).getDuration()); int acc = 0; for (DurationList::iterator i = dlist.begin(); i != dlist.end(); ++i) { cout << "duration: " << *i << endl; acc += *i; } cout << "total: " << acc << " (on bar duration of " << ts.getBarDuration() << ")" << endl; cout << "4/4 96/96..." << endl; ts = TimeSignature(4,4); dlist = DurationList(); ts.getDurationListForInterval(dlist, 96, 96); acc = 0; for (DurationList::iterator i = dlist.begin(); i != dlist.end(); ++i) { cout << "duration: " << *i << endl; acc += *i; } cout << "total: " << acc << " (on bar duration of " << ts.getBarDuration() << ")" << endl; cout << "6/8..." << endl; ts = TimeSignature(6,8); dlist = DurationList(); ts.getDurationListForInterval (dlist, 1209, ts.getBarDuration() - Note(Note::Semiquaver, true).getDuration()); acc = 0; for (DurationList::iterator i = dlist.begin(); i != dlist.end(); ++i) { cout << "duration: " << *i << endl; acc += *i; } cout << "total: " << acc << " (on bar duration of " << ts.getBarDuration() << ")" << endl; cout << "3/4..." << endl; ts = TimeSignature(3,4); dlist = DurationList(); ts.getDurationListForInterval (dlist, 1209, ts.getBarDuration() - Note(Note::Semiquaver, true).getDuration()); acc = 0; for (DurationList::iterator i = dlist.begin(); i != dlist.end(); ++i) { cout << "duration: " << *i << endl; acc += *i; } cout << "total: " << acc << " (on bar duration of " << ts.getBarDuration() << ")" << endl; cout << "4/4..." << endl; ts = TimeSignature(4,4); dlist = DurationList(); ts.getDurationListForInterval (dlist, 1209, ts.getBarDuration() - Note(Note::Semiquaver, true).getDuration()); acc = 0; for (DurationList::iterator i = dlist.begin(); i != dlist.end(); ++i) { cout << "duration: " << *i << endl; acc += *i; } cout << "total: " << acc << " (on bar duration of " << ts.getBarDuration() << ")" << endl; cout << "3/8..." << endl; ts = TimeSignature(3,8); dlist = DurationList(); ts.getDurationListForInterval (dlist, 1209, ts.getBarDuration() - Note(Note::Semiquaver, true).getDuration()); acc = 0; for (DurationList::iterator i = dlist.begin(); i != dlist.end(); ++i) { cout << "duration: " << *i << endl; acc += *i; } cout << "total: " << acc << " (on bar duration of " << ts.getBarDuration() << ")" << endl; cout << "4/4 wacky placement..." << endl; ts = TimeSignature(4,4); dlist = DurationList(); ts.getDurationListForInterval(dlist, 160, 1280); acc = 0; for (DurationList::iterator i = dlist.begin(); i != dlist.end(); ++i) { cout << "duration: " << *i << endl; acc += *i; } cout << "total: " << acc << " (on bar duration of " << ts.getBarDuration() << ")" << endl; cout << "Testing Segment::splitIntoTie() - splitting 384 -> 2*192\n"; Composition c; Segment *ht = new Segment(); c.addSegment(ht); Segment &t(*ht); SegmentNotationHelper nh(t); SegmentPerformanceHelper ph(t); Event *ev = new Event("note", 0, 384); ev->set<Int>("pitch", 60); t.insert(ev); Segment::iterator sb(t.begin()); nh.splitIntoTie(sb, 384/2); for(Segment::iterator i = t.begin(); i != t.end(); ++i) { cout << "Event at " << (*i)->getAbsoluteTime() << " - duration : " << (*i)->getDuration() << endl; } Segment::iterator half2 = t.begin(); ++half2; cout << "Splitting 192 -> (48 + 144) : \n"; sb = t.begin(); nh.splitIntoTie(sb, 48); for(Segment::iterator i = t.begin(); i != t.end(); ++i) { cout << "Event at " << (*i)->getAbsoluteTime() << " - duration : " << (*i)->getDuration() << endl; } cout << "Splitting 192 -> (144 + 48) : \n"; nh.splitIntoTie(half2, 144); for(Segment::iterator i = t.begin(); i != t.end(); ++i) { cout << "Event at " << (*i)->getAbsoluteTime() << " - duration : " << (*i)->getDuration() << " - performance duration : " << ph.getSoundingDuration(i) << endl; cout << endl; (*i)->dump(cout); cout << endl; } nh.autoBeam(t.begin(), t.end(), "beamed");#endif // TEST_NOTATION_TYPES};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -