Ejemplo n.º 1
0
void PerformanceManager::loadPerformances() {

	IffStream* iffStream = TemplateManager::instance()->openIffFile(
			"datatables/performance/performance.iff");

	if (iffStream == NULL) {
		error("Could not open performances datatable.");
		return;
	}

	DataTableIff dtable;
	dtable.readObject(iffStream);

	delete iffStream;

	performances = new Vector<Performance*> ();
	for (int i = 0; i < dtable.getTotalRows(); ++i) {
		DataTableRow* row = dtable.getRow(i);

		Performance* performance = new Performance();
		performance->parseDataTableRow(row);
		performances->add(performance);
	}

	info("Loaded " + String::valueOf(performances->size()) + " performances.",
			true);
}
Ejemplo n.º 2
0
Vector<Performance*> PerformanceManager::getPerformanceListFromMod(
		const String& requiredSkillMod, int playerSkillModValue, int instrument) {
	String instrumentName = "";
	if (instrument != 0)
		instrumentName = getInstrument(instrument);

	Vector<Performance*> performanceList;

	if (performances != NULL) {

		for (int i = 0; i < performances->size(); ++i) {
			Performance* perform = performances->get(i);
			if (perform->getRequiredSkillMod() == requiredSkillMod
					&& perform->getRequiredSkillModValue()
							<= playerSkillModValue) {
				if (instrumentName != "") {
					//Should be a music call, look only for performances with that instrument
					if (instrumentName == perform->getRequiredInstrument())
						performanceList.add(perform);
				} else {
					//Should be a dance call
					performanceList.add(perform);
				}
			}
		}

	}

	return performanceList;
}
Ejemplo n.º 3
0
void run() {
	Performance p;

	printf("Allocating buffers\n");

	text_buf = alloc_shared_buffer<char> (LENGTH_OF_TEXT, &text_c);
	pattern_buf= alloc_shared_buffer<char> (LENGTH_OF_PATTERN, &pattern_c);
	result_buf= alloc_shared_buffer<char> (1, &result_c);
	result_c[0] = 0;

	init_string( text_c, pattern_c );

	printf("Initializing kernels\n");
	size_t task_dim = 1;
	clKernelSet kernel_set (device, context, program);
//	kernel_set.addKernel ("text_processor", 1, &task_dim, text_buf, LENGTH_OF_TEXT);
//	kernel_set.addKernel ("word_processor", 1, &task_dim);
	kernel_set.addKernel ("word_processor", 1, &task_dim, text_buf, LENGTH_OF_TEXT);
	kernel_set.addKernel ("matching", 1, &task_dim, pattern_buf, LENGTH_OF_PATTERN, result_buf);

	printf("Launching the kernel...\n");
	p.start();
	kernel_set.launch();

	printf(" start waiting.... \n");
	kernel_set.finish();


	p.stop();
	printf(" done Execution (OpenCL Channel) time = (%u,%u), result = %d\n", p.report_sec(), p.report_usec(),result_c[0]);

	test_in_cpu( text_c, pattern_c );

	return;
}
static v8::Handle<v8::Value> webkitClearMeasuresCallback(const v8::Arguments& args)
{
    Performance* imp = V8Performance::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, measureName, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsNullString));
    imp->webkitClearMeasures(measureName);
    return v8Undefined();
}
static void onwebkitresourcetimingbufferfullAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    Performance* imp = V8Performance::toNative(info.Holder());
    transferHiddenDependency(info.Holder(), imp->onwebkitresourcetimingbufferfull(), value, V8Performance::eventListenerCacheIndex);
    imp->setOnwebkitresourcetimingbufferfull(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate));
    return;
}
static v8::Handle<v8::Value> webkitGetEntriesByTypeCallback(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    Performance* imp = V8Performance::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, entryType, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    return toV8(imp->webkitGetEntriesByType(entryType), args.Holder(), args.GetIsolate());
}
static v8::Handle<v8::Value> webkitSetResourceTimingBufferSizeCallback(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    Performance* imp = V8Performance::toNative(args.Holder());
    V8TRYCATCH(unsigned, maxSize, toUInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
    imp->webkitSetResourceTimingBufferSize(maxSize);
    return v8Undefined();
}
Ejemplo n.º 8
0
int main()
{
	Performance P; //Initializes an instance of the Performance class.
	P.run(2,20); //first parameter is the number of standard deviations for bands. 
				 //Second parameter is the number of periods in the moving average.
	cout<< "Sharpe Ratio: " << P.sharpe_ratio() << endl;
	
	system("pause");
}
Ejemplo n.º 9
0
//-----------------------------------------------------------------------------
//! 描画
//-----------------------------------------------------------------------------
void SystemPerformance::drawPerformanceBar()
{

	glDepthMask(GL_FALSE);
	setBlendMode(BM_BLEND_ALPHA);

	// 描画座標
	Vector3 drawPos = Vector3(1860.0f, 0.0f, 0.0f);

	// フレームの数
	static u32 frameCount = 3;
	// 線形補完する
	static f32 height = 1000.0f;
	// 1フレーム分の高さ
	static f32 oneFrameHeight = height / (f32)frameCount;
	

	// 枠を描画
	glColor4f(0.0f,0.0f,0.0f, 0.8f);
	glBegin(GL_TRIANGLE_STRIP);
		glVertex3f(drawPos._x	     , drawPos._y	 	  , 0.0f);
		glVertex3f(drawPos._x + 40.0f, drawPos._y		  , 0.0f);
		glVertex3f(drawPos._x		 , drawPos._y + height, 0.0f);
		glVertex3f(drawPos._x + 40.0f, drawPos._y + height, 0.0f);
	glEnd();

	// 枠の分だけずらす
	drawPos._x += 5.0f;

	

	// 描画
	for( list<Performance*>::iterator itr = _pPerformList.begin(); itr != _pPerformList.end(); itr++ )
	{
		Performance*	drawPef = *itr;
		// 描画
		drawPef->DrawPerformance(drawPos, oneFrameHeight, _maxSecond);
		// 次の描画位置を求める
		drawPos._y += drawPef->getHeight();
	}

	//---- フレームの分割線の描画
	drawPos._x -= 5.0f;
	glBegin(GL_LINES);
	glColor4f(0.0f, 1.0f, 0.5f, 1.0f);
	for( u32 i=0; i<frameCount; ++i ){
		glVertex3f(drawPos._x		 , i * oneFrameHeight, 0.0f);
		glVertex3f(drawPos._x + 40.0f, i * oneFrameHeight, 0.0f);
	}
	glEnd();

	// 白で設定しなおす
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	setBlendMode(BM_NONE);
	glDepthMask(GL_TRUE);
}
Ejemplo n.º 10
0
Performance* PerformanceManager::getSong(const String& name, int instrumentType) {
	if (performances != NULL) {
		for (int i = 0; i < performances->size(); ++i) {
			Performance* ret = performances->get(i);

			if (ret->isMusic() && ret->getName() == name
					&& ret->getInstrumentAudioId() == instrumentType)
				return ret;
		}
	}
	return NULL;
}
Ejemplo n.º 11
0
Performance* PerformanceManager::getDance(const String& name) {
	if (performances != NULL) {
		for (int i = 0; i < performances->size(); ++i) {
			Performance* ret = performances->get(i);

			if (ret->isDance() && ret->getName() == name)
				return ret;
		}
	}

	return NULL;
}
static v8::Handle<v8::Value> memoryAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    Performance* imp = V8Performance::toNative(info.Holder());
    RefPtr<MemoryInfo> result = imp->memory();
    v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Undefined();
    if (wrapper.IsEmpty()) {
        wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
        if (!wrapper.IsEmpty())
            V8DOMWrapper::setNamedHiddenReference(info.Holder(), "memory", wrapper);
    }
    return wrapper;
}
void EntertainingSessionImplementation::doPerformanceAction() {
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();

	if (entertainer == NULL)
		return;

	Locker locker(entertainer);

	Performance* performance = NULL;

	PerformanceManager* performanceManager = SkillManager::instance()->getPerformanceManager();
	ManagedReference<Instrument*> instrument = getInstrument(entertainer);

	if (isDancing())
		performance = performanceManager->getDance(performanceName);
	else if (isPlayingMusic() && instrument)
		performance = performanceManager->getSong(performanceName, instrument->getInstrumentType());
	else {
		cancelSession();
		return;
	}

	if (performance == NULL) { // shouldn't happen
		StringBuffer msg;
		msg << "Performance was null.  Please report to www.swgemu.com/bugs ! Name: " << performanceName << " and Type: " << dec << instrument->getInstrumentType();

		entertainer->sendSystemMessage(msg.toString());
		return;
	}

	int actionDrain = performance->getActionPointsPerLoop();

	//Adjust cost based upon player's quickness
	actionDrain = entertainer->calculateCostAdjustment(CreatureAttribute::QUICKNESS, actionDrain);

	if (entertainer->getHAM(CreatureAttribute::ACTION) <= actionDrain) {
		if (isDancing()) {
			stopDancing();
			entertainer->sendSystemMessage("@performance:dance_too_tired");
		}

		if (isPlayingMusic()) {
			stopPlayingMusic();
			entertainer->sendSystemMessage("@performance:music_too_tired");
		}
	} else {
		entertainer->inflictDamage(entertainer, CreatureAttribute::ACTION, actionDrain, false, true);
	}
}
Ejemplo n.º 14
0
already_AddRefed<VideoPlaybackQuality>
HTMLVideoElement::GetVideoPlaybackQuality() {
  DOMHighResTimeStamp creationTime = 0;
  uint32_t totalFrames = 0;
  uint32_t droppedFrames = 0;
  uint32_t corruptedFrames = 0;

  if (IsVideoStatsEnabled()) {
    if (nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow()) {
      Performance* perf = window->GetPerformance();
      if (perf) {
        creationTime = perf->Now();
      }
    }

    if (mDecoder) {
      if (nsContentUtils::ShouldResistFingerprinting(OwnerDoc())) {
        totalFrames = nsRFPService::GetSpoofedTotalFrames(TotalPlayTime());
        droppedFrames = nsRFPService::GetSpoofedDroppedFrames(
            TotalPlayTime(), VideoWidth(), VideoHeight());
        corruptedFrames = 0;
      } else {
        FrameStatistics* stats = &mDecoder->GetFrameStatistics();
        if (sizeof(totalFrames) >= sizeof(stats->GetParsedFrames())) {
          totalFrames = stats->GetTotalFrames();
          droppedFrames = stats->GetDroppedFrames();
        } else {
          uint64_t total = stats->GetTotalFrames();
          const auto maxNumber = std::numeric_limits<uint32_t>::max();
          if (total <= maxNumber) {
            totalFrames = uint32_t(total);
            droppedFrames = uint32_t(stats->GetDroppedFrames());
          } else {
            // Too big number(s) -> Resize everything to fit in 32 bits.
            double ratio = double(maxNumber) / double(total);
            totalFrames = maxNumber;  // === total * ratio
            droppedFrames = uint32_t(double(stats->GetDroppedFrames()) * ratio);
          }
        }
        corruptedFrames = 0;
      }
    }
  }

  RefPtr<VideoPlaybackQuality> playbackQuality = new VideoPlaybackQuality(
      this, creationTime, totalFrames, droppedFrames, corruptedFrames);
  return playbackQuality.forget();
}
static v8::Handle<v8::Value> webkitMarkCallback(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    Performance* imp = V8Performance::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, markName, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    imp->webkitMark(markName, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
void EntertainingSessionImplementation::increaseEntertainerBuff(CreatureObject* patron){
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();

	PerformanceManager* performanceManager = SkillManager::instance()->getPerformanceManager();
	Performance* performance = NULL;

	ManagedReference<Instrument*> instrument = getInstrument(entertainer);

	if (performanceName == "")
		return;

	if (dancing) {
		performance = performanceManager->getDance(performanceName);
	} else if (playingMusic && instrument != NULL) {
		performance = performanceManager->getSong(performanceName, instrument->getInstrumentType());
	} else {
		cancelSession();
		return;
	}

	if(!canGiveEntertainBuff())
		return;

	if (performance == NULL) { // shouldn't happen
		return;
	}

	ManagedReference<PlayerObject*> entPlayer = entertainer->getPlayerObject();
	//Check if the patron is a valid buff target
	//Whether it be passive(in the same group) or active (/setPerform target)
	if ((!entertainer->isGrouped() || entertainer->getGroupID() != patron->getGroupID())
			&& entPlayer->getPerformanceBuffTarget() != patron->getObjectID()) {
		return;
	}

	if(isInDenyServiceList(patron))
		return;

	float buffAcceleration = 1 + ((float)entertainer->getSkillMod("accelerate_entertainer_buff") / 100.f);

	addEntertainerBuffDuration(patron, performance->getType(), 2.0f * buffAcceleration);
	addEntertainerBuffStrength(patron, performance->getType(), performance->getHealShockWound());

}
Ejemplo n.º 17
0
int main(int argc, char* argv[]) {
  using namespace asmjit;

  Performance perf;
  uint32_t kNumRepeats = 10;
  uint32_t kNumIterations = 10000;

  JitRuntime runtime;
  X86Assembler a(&runtime);
  X86Compiler c(&runtime);

  uint32_t r, i;

  // --------------------------------------------------------------------------
  // [Bench - Opcode]
  // --------------------------------------------------------------------------

  perf.reset();
  for (r = 0; r < kNumRepeats; r++) {
    perf.start();
    for (i = 0; i < kNumIterations; i++) {
      asmgen::opcode(a);

      void *p = a.make();
      runtime.release(p);

      a.reset();
    }
    perf.end();
  }

  printf("Opcode   | Time: %-6u [ms] | Speed: %-9u [inst/s]\n",
    perf.best, instPerMs(perf.best, kNumIterations, asmgen::kGenOpCodeInstCount));

  // --------------------------------------------------------------------------
  // [Bench - Blend]
  // --------------------------------------------------------------------------

  perf.reset();
  for (r = 0; r < kNumRepeats; r++) {
    perf.start();
    for (i = 0; i < kNumIterations; i++) {
      asmgen::blend(c);

      void* p = c.make();
      runtime.release(p);

      c.reset();
    }
    perf.end();
  }

  printf("Blend    | Time: %-6u [ms] | Speed: %-9u [inst/s]\n",
    perf.best, instPerMs(perf.best, kNumIterations, asmgen::kGenBlendInstCount));

  return 0;
}
Ejemplo n.º 18
0
void performanceGate() {
	std::vector<double> input;
	input.resize(8192, 0);
	std::vector<double> output;
	output.resize(8192, 0);
	double sampleRate = 48000.0;
	{
		double phase = 0;
		double baseCycle = 2.0*M_PI/sampleRate * 1280.0;
		for (int32_t iii=0; iii<input.size(); iii++) {
			input[iii] = cos(phase) * 5.0;
			phase += baseCycle;
			if (phase >= 2*M_PI) {
				phase -= 2*M_PI;
			}
		}
	}
	TEST_PRINT("Start Gate performance ...");
	Performance perfo;
	audio::algo::chunkware::Gate algo;
	algo.setSampleRate(48000);
	algo.setThreshold(0);
	algo.setAttack(0.1);
	algo.setRelease(2);
	algo.init();
	for (int32_t iii=0; iii<4096; ++iii) {
		perfo.tic();
		algo.process(&output[0], &input[0], input.size(), 1, audio::format_double);
		perfo.toc();
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
	}
	TEST_PRINT("Performance Gate (double): ");
	TEST_PRINT("    blockSize=" << input.size() << " sample");
	TEST_PRINT("    min < avg < max =" << perfo.getMinProcessing().count() << "ns < "
	                                   << perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration() << "ns < "
	                                   << perfo.getMaxProcessing().count() << "ns ");
	TEST_PRINT("    min < avg < max = " << (float((perfo.getMinProcessing().count()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "% < "
	                                    << (float(((perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration())*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "% < "
	                                    << (float((perfo.getMaxProcessing().count()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "%");
}
Ejemplo n.º 19
0
void test_in_cpu( char* text, char* pattern )
{
	Performance p;
	p.start();

	bool match = false;
	int count = 0;
	for( int n = 0 ; n < LENGTH_OF_TEXT - 1; n ++ ) { 
		int m = 0;
		if( n == 0 || text[n-1] == ' ' ) {
			for( ; m < LENGTH_OF_PATTERN - 1; m ++ ) {
				if( pattern[m] != text[n+m] )
					break;
			}
		}
		if( m == LENGTH_OF_PATTERN - 1 )
			count ++;
	}

	p.stop();

	printf(" done Execution (CPU) time = (%u,%u), result = %d\n", p.report_sec(), p.report_usec(),count);
}
Ejemplo n.º 20
0
//-----------------------------------------------------------------------------
//! 描画
//-----------------------------------------------------------------------------
void Performance::DrawPerformance(Vector3 drawPos, f32& parentHeight, s64& maxFrame)
{
	// 線形補完する
	_height = LinearInterpolation(0.0f, parentHeight, (f32)_totalTime, (f32)maxFrame);
	// 自分のバーの描画	
	glBegin(GL_TRIANGLE_STRIP);
		glColor4ubv((GLubyte*)&_drawColor);
		glVertex3f(drawPos._x	     , drawPos._y	 	   , 0.0f);
		glVertex3f(drawPos._x + 30.0f, drawPos._y		   , 0.0f);
		glVertex3f(drawPos._x		 , drawPos._y + _height, 0.0f);
		glVertex3f(drawPos._x + 30.0f, drawPos._y + _height, 0.0f);
	glEnd();

	// 子のパフォーマンスの描画
	for( list<Performance*>::iterator itr = _childPeform.begin(); itr != _childPeform.end(); itr++ )
	{
		Performance*	drawPef = *itr;
		// 描画
		drawPef->DrawPerformance(drawPos, _height, _totalTime);
		// 次の描画位置を求める
		drawPos._y += drawPef->getHeight();
	}

}
Ejemplo n.º 21
0
int main(int argc, char **argv)
{
    char mode;
    int fsize;
    struct timeval start;
    double dur;
    char *filepath, *filepaths, *tofree;
    Performance perf;

    if ( argc != 6 ) {
        cout << "usage: ./me r|w filepaths filesize addition-head additional-datarow" << endl;
        cout << "example: ./perform w /tmp/myfile1,/tmp/myfile2 1024 'hello hellodata' 'echo echodata'" << endl;
        exit(1);
    }
    
    mode = argv[1][0];
    tofree = filepaths = strdup(argv[2]);
    fsize = atoi(argv[3]);
    
    start_timer(&start);

    while ((filepath = strsep(&filepaths, ",")) != NULL) {
        if ( mode == 'r' )
            readfile(filepath, fsize);
        else
            writefile(filepath, fsize);
    }

    dur = end_timer_get_duration(&start);

    perf.put("duration", dur);
    perf.put("filesize", fsize);
    perf.put("mode", argv[1]);
    perf.put(argv[4], argv[5]);
    cout << perf.showColumns();

    free(tofree);
}
void EntertainingSessionImplementation::doFlourish(int flourishNumber) {
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();

	int fid = flourishNumber;

	if (!dancing && !playingMusic) {
		entertainer->sendSystemMessage("@performance:flourish_not_performing");
		return;
	}

	PerformanceManager* performanceManager = SkillManager::instance()->getPerformanceManager();
	Performance* performance = NULL;
	ManagedReference<Instrument*> instrument = getInstrument(entertainer);

	if (dancing)
		performance = performanceManager->getDance(performanceName);
	else if (playingMusic && instrument)
		performance = performanceManager->getSong(performanceName, instrument->getInstrumentType());
	else {
		cancelSession();
		return;
	}

	if (!performance) { // shouldn't happen
		StringBuffer msg;
		msg << "Performance was null.  Please report to www.swgemu.com/bugs ! Name: " << performanceName << " and Type: " << dec << instrument->getInstrumentType();

		entertainer->sendSystemMessage(msg.toString());
		return;
	}

	float baseActionDrain = performance->getActionPointsPerLoop() - (int)(entertainer->getHAM(CreatureAttribute::QUICKNESS)/35.f);

	//float baseActionDrain = -40 + (getQuickness() / 37.5);
	float flourishActionDrain = baseActionDrain / 2.0;

	int actionDrain = (int)round((flourishActionDrain * 10 + 0.5) / 10.0); // Round to nearest dec for actual int cost

	if (entertainer->getHAM(CreatureAttribute::ACTION) <= actionDrain) {
		entertainer->sendSystemMessage("@performance:flourish_too_tired");
	} else {
		entertainer->inflictDamage(entertainer, CreatureAttribute::ACTION, actionDrain, false, true);

		if (dancing) {
			StringBuffer msg;
			msg << "skill_action_" << fid;
			entertainer->doAnimation(msg.toString());
		} else if (playingMusic) {
			Flourish* flourish = new Flourish(entertainer, fid);
			entertainer->broadcastMessage(flourish, true);
		}

		//check to see how many flourishes have occurred this tick
		if(flourishCount < 5) {
			// Add buff
			addEntertainerFlourishBuff();

			// Grant Experience
			if(flourishCount < 2)
				flourishXp += performance->getBaseXp() + performance->getFlourishXpMod();

			flourishCount++;
		}
		entertainer->notifyObservers(ObserverEventType::FLOURISH, entertainer, fid);

		entertainer->sendSystemMessage("@performance:flourish_perform");
	}
}
void EntertainingSessionImplementation::doEntertainerPatronEffects() {
	ManagedReference<CreatureObject*> creo = entertainer.get();

	if (creo == NULL)
		return;

	if (performanceName == "")
		return;

	Locker locker(creo);

	//**DECLARATIONS**
	VectorMap<ManagedReference<CreatureObject*>, EntertainingData>* patrons = NULL;

	SkillManager* skillManager = creo->getZoneServer()->getSkillManager();

	PerformanceManager* performanceManager = skillManager->getPerformanceManager();
	Performance* performance = NULL;

	ManagedReference<Instrument*> instrument = getInstrument(creo);

	float woundHealingSkill = 0.0f;
	float playerShockHealingSkill = 0.0f;
	float buildingShockHealingSkill = creo->getSkillMod("private_med_battle_fatigue");
	float factionPerkSkill = creo->getSkillMod("private_faction_mind_heal");

	//**LOAD PATRONS, GET THE PERFORMANCE AND ENT'S HEALING SKILL.**
	if (dancing) {
		patrons = &watchers;
		performance = performanceManager->getDance(performanceName);
		woundHealingSkill = (float) creo->getSkillMod("healing_dance_wound");
		playerShockHealingSkill = (float) creo->getSkillMod("healing_dance_shock");
	} else if (playingMusic && instrument != NULL) {
		patrons = &listeners;
		performance = performanceManager->getSong(performanceName, instrument->getInstrumentType());
		woundHealingSkill = (float) creo->getSkillMod("healing_music_wound");
		playerShockHealingSkill = (float) creo->getSkillMod("healing_music_shock");

	} else {
		cancelSession();
		return;
	}

	if (performance == NULL) {
		return;
	}

	ManagedReference<BuildingObject*> building = creo->getRootParent().get().castTo<BuildingObject*>();

	if (building != NULL && factionPerkSkill > 0 && building->isPlayerRegisteredWithin(creo->getObjectID())) {
		unsigned int buildingFaction = building->getFaction();
		unsigned int healerFaction = creo->getFaction();
		PlayerObject* ghost = creo->getPlayerObject();

		if (ghost != NULL && healerFaction != 0 && healerFaction == buildingFaction && ghost->getFactionStatus() == FactionStatus::OVERT) {
			woundHealingSkill += factionPerkSkill;
			playerShockHealingSkill += factionPerkSkill;
		}
	}

	//**DETERMINE WOUND HEAL AMOUNTS.**
	int woundHeal = ceil(performance->getHealMindWound() * (woundHealingSkill / 100.0f));
	int shockHeal = ceil(performance->getHealShockWound() * ((playerShockHealingSkill + buildingShockHealingSkill) / 100.0f));

	//**ENTERTAINER HEALS THEIR OWN MIND.**
	healWounds(creo, woundHeal*(flourishCount+1), shockHeal*(flourishCount+1));

	//**APPLY EFFECTS TO PATRONS.**
	if (patrons != NULL && patrons->size() > 0) {

		for (int i = 0; i < patrons->size(); ++i) {
			ManagedReference<CreatureObject*> patron = patrons->elementAt(i).getKey();

			try {
				//**VERIFY THE PATRON IS NOT ON THE DENY SERVICE LIST

				if (creo->isInRange(patron, 10.0f)) {
					healWounds(patron, woundHeal*(flourishCount+1), shockHeal*(flourishCount+1));
					increaseEntertainerBuff(patron);

				} else { //patron is not in range, force to stop listening
					ManagedReference<PlayerManager*> playerManager = patron->getZoneServer()->getPlayerManager();

					Locker locker(patron, entertainer.get());

					if (dancing) {
						if (playerManager != NULL)
							playerManager->stopWatch(patron, creo->getObjectID(), true, false, false, true);

						if (!patron->isListening())
							sendEntertainmentUpdate(patron, 0, "", true);

					} else if (playingMusic) {
						if (playerManager != NULL)
							playerManager->stopListen(patron, creo->getObjectID(), true, false, false, true);

						if (!patron->isWatching())
							sendEntertainmentUpdate(patron, 0, "", true);
					}
				}

			} catch (Exception& e) {
				error("Unreported exception caught in EntertainingSessionImplementation::doEntertainerPatronEffects()");
			}
		}
	} //else
	//System::out << "There are no patrons.\n";


	info("EntertainingSessionImplementation::doEntertainerPatronEffects() end");
}
Ejemplo n.º 24
0
int main( int argc, char** argv )
{
    string reference;
    string input_dir;
    string ground_truth_dir;
    static int verbose_flag;
    int option_index = 0;
    int c;
   
    
    static struct option long_options[] = {
        {"verbose", no_argument,       &verbose_flag, 1},
        {"brief",   no_argument,       &verbose_flag, 0},
        {"img",  required_argument, 0, 'i'},
        {0, 0, 0, 0}
    };
    
    while ((c = getopt_long(argc, argv, "r:i:",
                            long_options, &option_index)) != -1) {
        if (c == -1)
            break;
        switch (c) {
        case 'i':
            ground_truth_dir = optarg;
            break;
        case 'h':
        case '?':
            display_usage();
            break;
        default:
            abort ();
        }
        
    }


    // Read files from input directory
    string output_dir ("dscore_map");
    if ( !exists(path(output_dir)) )
        create_directory(output_dir);
    
    map<unsigned int, string> gt_files;
    int gt_size = -1;

    // Verify input name is a video file or sequences of jpg files
    path path_to_ground_truth ( chomp(ground_truth_dir) );
    //path path_to_ground_truth (ground_truth_dir.c_str());

    if (is_directory(path_to_ground_truth)) {

        // fills list gt_files with  <number,file_number>
        list_files(ground_truth_dir,gt_files);
        gt_size = gt_files.size();

        output_dir += "/" + path_to_ground_truth.filename().string();

        // Create local directory to save xml maps.
        if ( !exists(path(output_dir)) )
            create_directory(output_dir);

    } 
    else {
        cout << "Invalid ground-truth directory ... "<< endl;
        return 0;
    }


    

    map<unsigned int, string>::iterator gt_it;

    Performance *measure = new Performance();

    Mat Image;
    Mat Map;
    
    
    for (gt_it = gt_files.begin(); gt_it != gt_files.end(); ++gt_it) {
        
        Image  = Scalar::all(0);
        Map    = Scalar::all(0);
        
        // open ground truth frame.
        Image = imread(gt_it->second, CV_LOAD_IMAGE_GRAYSCALE);
        
        // get general Map
        measure->computeGeneralDSCoreMap(Image, Map);
        
        string dirname = fileName(gt_it->second);
        cout << dirname << endl;

        
        stringstream mapfile;
        mapfile << output_dir << "/" << gt_it->first << ".xml";
        FileStorage fs(mapfile.str(), FileStorage::WRITE);
        stringstream tagname;
        tagname << "DSCORE" << gt_it->first;
        fs << "DSCORE" << Map;
        fs.release();
        
        // just for testing
        if (gt_it->first == (unsigned int)(gt_size/2)) {
            
            Mat mask;
            stringstream map_name;
            map_name << "Map_" << gt_it->first ;

            cout << "Looking for: "<< map_name.str() << endl;

            FileStorage fsread(mapfile.str(), FileStorage::READ);
            fsread["DSCORE"] >> mask;
            fsread.release();
            
            map_name.str("");
            map_name << gt_it->first << ".png" ;
            normalize(mask, mask, 0, 255, cv::NORM_MINMAX);
            imwrite(map_name.str().c_str(), mask);
            
        }
        
    }
static v8::Handle<v8::Value> onwebkitresourcetimingbufferfullAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    Performance* imp = V8Performance::toNative(info.Holder());
    return imp->onwebkitresourcetimingbufferfull() ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(imp->onwebkitresourcetimingbufferfull())->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8Null(info.GetIsolate()));
}
static v8::Handle<v8::Value> nowCallback(const v8::Arguments& args)
{
    Performance* imp = V8Performance::toNative(args.Holder());
    return v8::Number::New(imp->now());
}
Ejemplo n.º 27
0
int main(int _argc, const char** _argv) {
	// the only one init for etk:
	etk::init(_argc, _argv);
	std::string inputName = "";
	bool performance = false;
	bool perf = false;
	int64_t sampleRate = 48000;
	for (int32_t iii=0; iii<_argc ; ++iii) {
		std::string data = _argv[iii];
		if (etk::start_with(data,"--in=")) {
			inputName = &data[5];
		} else if (data == "--performance") {
			performance = true;
		} else if (data == "--perf") {
			perf = true;
		} else if (etk::start_with(data,"--sample-rate=")) {
			data = &data[14];
			sampleRate = etk::string_to_int32_t(data);
		} else if (    data == "-h"
		            || data == "--help") {
			TEST_PRINT("Help : ");
			TEST_PRINT("    ./xxx --fb=file.raw --mic=file.raw");
			TEST_PRINT("        --in=YYY.raw        inout file");
			TEST_PRINT("        --performance       Generate signal to force algo to maximum process time");
			TEST_PRINT("        --perf              Enable performence test (little slower but real performence test)");
			TEST_PRINT("        --sample-rate=XXXX  Signal sample rate (default 48000)");
			exit(0);
		}
	}
	// PERFORMANCE test only ....
	if (performance == true) {
		performanceCompressor();
		performanceLimiter();
		performanceGate();
		return 0;
	}
	if (inputName == "") {
		TEST_ERROR("Can not Process missing parameters...");
		exit(-1);
	}
	TEST_INFO("Read input:");
	std::vector<double> inputData = convert(etk::FSNodeReadAllDataType<int16_t>(inputName));
	TEST_INFO("    " << inputData.size() << " samples");
	// resize output :
	std::vector<double> output;
	output.resize(inputData.size(), 0);
	// process in chunk of 256 samples
	int32_t blockSize = 256;
	
	Performance perfo;
	/*
	audio::algo::chunkware::Compressor algo;
	algo.setThreshold(-10);
	algo.setRatio(-5);
	int32_t lastPourcent = -1;
	for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
		if (lastPourcent != 100*iii / (output.size()/blockSize)) {
			lastPourcent = 100*iii / (output.size()/blockSize);
			TEST_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
		} else {
			TEST_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
		}
		perfo.tic();
		algo.process(audio::format_double, &output[iii*blockSize], &inputData[iii*blockSize], blockSize, 1);
		if (perf == true) {
			perfo.toc();
			std::this_thread::sleep_for(std::chrono::milliseconds(1));
		}
	}
	*/
	audio::algo::chunkware::Limiter algo;
	algo.setSampleRate(48000);
	algo.setThreshold(0);
	algo.setAttack(0.1);
	algo.setRelease(2);
	algo.init(1);
	int32_t lastPourcent = -1;
	for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
		if (lastPourcent != 100*iii / (output.size()/blockSize)) {
			lastPourcent = 100*iii / (output.size()/blockSize);
			TEST_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
		} else {
			TEST_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
		}
		perfo.tic();
		algo.process(&output[iii*blockSize], &inputData[iii*blockSize], blockSize, 1, audio::format_double);
		if (perf == true) {
			perfo.toc();
			std::this_thread::sleep_for(std::chrono::milliseconds(1));
		}
	}
	
	
	if (perf == true) {
		TEST_INFO("Performance Result: ");
		TEST_INFO("    blockSize=" << blockSize << " sample");
		TEST_INFO("    min=" << perfo.getMinProcessing().count() << " ns");
		TEST_INFO("    max=" << perfo.getMaxProcessing().count() << " ns");
		TEST_INFO("    avg=" << perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration() << " ns");
		
		TEST_INFO("    min=" << (float((perfo.getMinProcessing().count()*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
		TEST_INFO("    max=" << (float((perfo.getMaxProcessing().count()*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
		TEST_INFO("    avg=" << (float(((perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration())*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
	}
	etk::FSNodeWriteAllDataType<int16_t>("output.raw", convert(output));
	
}
static v8::Handle<v8::Value> webkitGetEntriesCallback(const v8::Arguments& args)
{
    Performance* imp = V8Performance::toNative(args.Holder());
    return toV8(imp->webkitGetEntries(), args.Holder(), args.GetIsolate());
}
Ejemplo n.º 29
0
static void benchX86(uint32_t arch, uint32_t callConv) {
  using namespace asmjit;

  Performance perf;
  TestRuntime runtime(arch, callConv);

  X86Assembler a(&runtime, arch);
  X86Compiler c;

  uint32_t r, i;

  const char* archName = arch == kArchX86 ? "X86" : "X64";

  // --------------------------------------------------------------------------
  // [Bench - Opcode]
  // --------------------------------------------------------------------------

  size_t asmOutputSize = 0;
  size_t cmpOutputSize = 0;

  perf.reset();
  for (r = 0; r < kNumRepeats; r++) {
    asmOutputSize = 0;
    perf.start();
    for (i = 0; i < kNumIterations; i++) {
      asmgen::opcode(a);

      void *p = a.make();
      runtime.release(p);

      asmOutputSize += a.getCodeSize();
      a.reset();
    }
    perf.end();
  }

  printf("%-12s (%s) | Time: %-6u [ms] | Speed: %7.3f [MB/s]\n",
    "X86Assembler", archName, perf.best, mbps(perf.best, asmOutputSize));

  // --------------------------------------------------------------------------
  // [Bench - Blend]
  // --------------------------------------------------------------------------

  perf.reset();
  for (r = 0; r < kNumRepeats; r++) {
    cmpOutputSize = 0;
    perf.start();
    for (i = 0; i < kNumIterations; i++) {
      c.attach(&a);
      asmgen::blend(c);
      c.finalize();

      void* p = a.make();
      runtime.release(p);

      cmpOutputSize += a.getCodeSize();
      a.reset();
    }
    perf.end();
  }

  printf("%-12s (%s) | Time: %-6u [ms] | Speed: %7.3f [MB/s]\n",
    "X86Compiler", archName, perf.best, mbps(perf.best, cmpOutputSize));
}
static v8::Handle<v8::Value> webkitClearResourceTimingsCallback(const v8::Arguments& args)
{
    Performance* imp = V8Performance::toNative(args.Holder());
    imp->webkitClearResourceTimings();
    return v8Undefined();
}